Why did David repent? David had committed adultery with Bathsheba and then had Bathsheba’s husband killed. He did that because he had gotten Bathsheba pregnant and wanted to legitimize the pregnancy. When he couldn’t orchestrate Uriah, the husband, into having sex with his wife, then he arranged for him to be killed in battle so that he could marry Bathsheba and make the pregnancy look right. One can wonder if there weren’t just a few people in the kingdom, and especially in the immediate neighbourhood, whose tongues were already wagging. And he was the king to boot.
In any case, in the progress of time David eventually repented of all the sins connected to this tragedy. He repented because he got gripped with his sin and what it was doing to him. This is clearly illustrated in Psalm 51:1-5. He finally came to his senses and realized that he was guilty of very grievous sins that had put serious distance between him and his God. In his word to Nathan, when Nathan had confronted him with his sin “I have sinned against the LORD (II Samuel 12:13).” All these things are true about why David repented. But that is not what I am getting at.
What got him to the point that he was willing to repent? At the spiritual level we can note that God is the Hound of Heaven and He loses none of all that He gives the Son. David was God’s and God had no intention of letting David get away, despite all of David’s efforts to do just that. But that is not what I am getting at either.
In short – David repented because he got caught. He repented because he was confronted with his sin. He repented because he was preached to. The prophet Nathan gets an audience with David and Nathan tells him this parable:
2 Samuel 12:1-6 – “… There were two men in a certain city, the one rich and the other poor.  The rich man had very many flocks and herds,  but the poor man had nothing but one little ewe lamb, which he had bought. And he brought it up, and it grew up with him and with his children. It used to eat of his morsel and drink from his cup and lie in his arms, and it was like a daughter to him.  Now there came a traveler to the rich man, and he was unwilling to take one of his own flock or herd to prepare for the guest who had come to him, but he took the poor man’s lamb and prepared it for the man who had come to him.”  Then David’s anger was greatly kindled against the man, and he said to Nathan, “As the Lord lives, the man who has done this deserves to die,  and he shall restore the lamb fourfold, because he did this thing, and because he had no pity.”
When David heard this parable it did nothing to bring him to repentance. His response shows us just what sin does to us. We are blinded to our own sins and very harsh on the same, or smaller sins, in others (See Matthew 18:23-35). There is not a hint of repentance in David when he states that the man who would steal a sheep is deserving of death. David is willing to execute a sheep stealer and when he says that to Nathan we find no repentance emanating from him about his own murder of a fellow human being. It does not occur to him that he has done something much worse. Not until Nathan says (and most preachers, at this point will say that Nathan pointed his finger right at David), “You are the man” and then explains to David how he is the man, that David comes to his senses and repents.
When Nathan explains to David that he is the man in the parable because of his adultery and murder, David says “I have sinned against the LORD”, Nathan responds with “The LORD also has put away your sin; you shall not die. Nevertheless, because by this deed you have utterly scorned the LORD, the child who is born to you shall die.”
That can’t be right. Surely we shouldn’t believe a man who half an hour ago was content to keep his sin hidden and now that he has been exposed says he’s sorry. Where is the proof of repentance? Where are the works of restoration? There will be consequences on David for the rest of his life. The baby died. God does not erase the results of our sins in this life. But Nathan is very clear. David has been forgiven. He is forgiven because of his repentance. Forgiveness is granted and pronounced before any proof of repentance takes place. Just like when you were saved.
When we were saved we prayed for Jesus to forgive us and He did. This is stunning grace. And it will not lead to sinful living. Grace like this leads to a repentant life. It leads to holiness. It leads to dependence upon God. It leads to gratitude.
What a thing God has done.