David is thinking, if I die in this sin, what is going to happen? Verse 4 suggests that David could not sense God in his life. That is why he says "return." He is telling God this: Come back from wherever You have gone. You are not here. Please return to me. Please save me. But He had not come back yet.
And so this made David think, if this goes on any longer and my health continues to deteriorate, how can I repent when I am dead? How can I get forgiveness when I am dead? How can I praise Him and thank Him for His forgiveness if I have died unforgiven? So he needed God's deliverance terribly. He wanted God's lovingkindness, which is here, "for Your mercy's sake." That is hesed. He says, "Save me for hesed's sake," my covenant loyalty. I am loyal to You, God. Save me and make this covenant work again. I am the guilty party, he is saying. For Your mercy's sake, let us have this covenant relationship mended.
So, we could say that verse 4 especially is a confession in itself. He did not want justice from God. He would surely die then because justice for sin is death, so he asked for mercy. He asked for forgiveness because he wanted the death penalty lifted, and that would have to be by grace.
There was nothing he could do to have that penalty lifted, so he needed for it to be done through mercy. It was unmerited pardon. He knew that he had sinned, but he was asking for it. Judge, give me mercy rather than justice in this situation.