God works through the mess anyway. David and Bathsheba, who came to be a couple through illegitimate means, ended up having two children who became part of the Messiah’s genealogy. That speaks volumes about God’s ability to redeem our worst mistakes. But there’s even more to the legacy of David’s humility than a couple of names in the sacred lineage. David wrote one of his best-known psalms in the immediate aftermath of his confession. Psalm 51 beautifully captures his grief and repentance. It pleads with God to create a pure heart in David, to renew his spirit, to maintain the presence of the Spirit in David’s life, and to restore the joy of his salvation. Then verse 13 declares what David would like to see happen in the aftermath of this whole affair: “Then I will teach transgressors your ways, and sinners will turn back to you.”

Isn’t it just like God to use the recorded words of David to answer his own prayer? After David asks for his joy to be restored and for his heart to be steadfast and for the opportunity to tell others about God’s ways, isn’t it just like God to say, “Okay, let’s include your prayer in My Word so it will cross cultures and centuries and show people what to do with their sin”? There wasn’t even a temple where sacrifices were made for sin in David’s time, but eventually a Messiah would come, not only to cover sin like a sacrifice but to remove it forever. And God would connect the dots of history through a descendant named after the most painful time in David’s life. Only our God does things like that.

David wanted his mistakes to be a learning opportunity for others, and his desire was granted. We continue to be moved by his words of repentance today. Millions throughout history have learned from them and been inspired by them. Millions more have been warned by David’s example of the dangers of self-deception and sin. God so thoroughly redeemed the awkward, painful, crisis moments of David’s life that they have impacted generation after generation of lives.