As for you, O Lord, you will not restrain your mercy from me; your steadfast love and your faithfulness will ever preserve me! -Psalm 40:11
Though the tone changes, the Psalmist is optimistic because the Lord is good. It is not because he (the Psalmist) is good (as he will confess), and not because all his enemies have ceased harassing him that he is optimistic, but because the Lord is good, the Psalmist is certain of being preserved.
Mercy is not getting what we actually deserve. To restrain mercy would be to impede or constrict its outpouring on his life; but the Lord has opened the floodgates of his mercy toward David because of his own (the Lord’s) steadfast (unchangeable) love and his faithfulness (consistency) despite David’s sins or failures.
Our confidence will always waiver if it is placed in our own ability to be good; when it is placed in the Lord, we can be sure he will preserve us. In other words, if the Lord extends mercy, there is no possibility of seeing it thwarted.
That’s worth contemplating.