Your words carry the ache of someone who has tasted grace yet feels crushed by the weight of their own failure. The thought that you don't deserve God's goodness isn't wrong in itself, that's almost the definition of grace. Grace is receiving exactly what you have not earned and could never earn. The trouble comes when that knowledge turns from a liberating truth into a quiet despair, as though your sin were greater than the gift He freely gives.
When you say you attached God's good deeds to your obedience, you've put your finger on something deeply human. We easily slip into thinking His favor rises and falls with our performance. But the gospel pulls the opposite direction: you are justified freely by His grace, apart from what you've done or left undone. The righteousness you stand in isn't your own. If it were, every stumble would indeed cast you down. But the standing you have is in Christ, who took upon Himself all your sin and guilt and gave you His own righteousness. God's goodness to you doesn't hang on the thin thread of your consistency; it rests on the finished work of Jesus.
Guilt has a way of whispering that you need to feel bad enough, to punish yourself a little, before you can come back. David knew that pull, he spoke of his sin being ever before him, and the crushing weight of his own bones broken by grief. But the relief he longed for didn't come from paying a price himself. It came from confession and the sheer mercy of God blotting out his transgression. When you confess, God doesn't partially forgive or hold back the full cleansing. He removes the guilt. He washes white as snow. The price was already taken by another. Your part is to receive that and let the joy and gladness David spoke of return.
This isn't soft permission to treat grace lightly, as if forgiveness were a license to keep falling in the same way without a fight. That would be to fail of grace entirely, to misunderstand what it means to be united with Christ in His death and raised to new life. But your heart doesn't sound like someone looking for a loophole. It sounds like someone who genuinely grieves and wants to honor God, yet is tempted to disqualify yourself from His love because you see the gap between who you are and who He calls you to be. Don't let your failures become a lens that only magnifies your unworthiness and fails to magnify the abundance of grace that outruns every sin.
Where sin abounded, grace overflowed. Not just a little. Overflowed. That doesn't make sin small; it makes grace vast. The very fact that you feel this ache shows the Spirit is at work, sharpening your conscience and drawing you back to the cross. Let that drawing end in peace. You are not the first to cry out, "I am a sinner," and you won't be the last. The wonder is that the same God who knows every dark corner declares you His beloved and calls you to stand in grace.
So by all means, thank Him. Let gratitude rise, not as a transaction to earn more favor, but as the natural breath of someone who has been forgiven much. Let Him use you as He wills, yes, but not from the posture of a servant afraid of dismissal. You are a child, and His grace trains you, not to walk on eggshells, but to walk freely and steadily in the righteousness He has already given. The bones He has broken, those griefs over sin, can be set right and made to rejoice. He does not despise a contrite heart. Let Him lift the guilt completely. That is grace, and it is enough.