This quote comes from the HUSH storyline, specifically Chapter 5 The Battle, or Batman Vol 1 #612.
Here's the scene:
To understand why he says this, it's important to know that he's fighting Superman at the time. In this case, he's fighting a Superman being controlled by Poison Ivy, courtesy of some kryptonite-laced lipstick.
The key phrase, right before the quote in question, is:
If you want to beat your opponent, Bruce, you have to think like your opponent.
Well, Clark doesn't think about unleashing everything he has to take down an enemy. He's trained himself to use as little of his godly power as necessary to end conflicts. His goodness affects him at a fundamental level, which we see as the fight continues. For example, Superman uses his ice breath to freeze hand with the kryptonite ring, and Bruce thinks this to himself:
Arctic breath. He's holding back as much as he can...
...and I have to keep the pressure on.
All through the fight, Batman is doing everything he can to pummel and distract Superman, leading to distracting Superman into destroying the power grid for Metropolis (although backups kick on immediately).
The difference between the two is pronounced. Bruce is a vigilante, operating outside the law, and he'll do whatever it takes to succeed in his mission. Maybe he won't kill, but he'll use sneaky tactics, tricks, and excessive force.
Including having Catwoman capture Lois Lane and have her thrown off of a building, all to get Superman to come to his senses and leave the fight. Although Superman wasn't happy about this.
He ends up thanking Batman anyway.
Why? Because, perhaps, deep-down, Bruce is a good person.
What the Hush storyline covers is a lot of Batman questioning himself, who he is, and what he's done. He's convinced himself he's not a good person, because of the way he works and the losses he's suffered (and maybe caused), such as the death of Jason Todd. We're not necessarily supposed to trust Batman's own evaluation of himself, in this case.
In the end, I believe he said those words because he's a man filled with regret, from not being good enough to protect all those he loves, and for isolating himself from everyone who would want to get close to him. Just as he's put up a wall between himself and all those others, he's put up a wall between his true self and how he decides to see himself.