Answer
Psalm 51 was written by King David after he committed adultery with Bathsheba and had her husband killed to cover his sin (2 Samuel 11). It has been said of David that he sinned big, but repented bigger. He is a model to us of what real heart repentance looks like. He wrote this psalm as an agonized cry to God for forgiveness.
Psalm 51:17 says, “My sacrifice, O God, is a broken spirit; a broken and contrite heart you, God, will not despise.” The meaning of this is connected with the verse just before it. Verse 16 says, “You do not delight in sacrifice, or I would bring it; you do not take pleasure in burnt offerings.” David is stating that there is nothing we can offer God to appease Him when we have sinned. More animal sacrifices were not what God was looking for. God desires true repentance.
Many people miss this truth. Rather than repent, they try to "clean up their act," give more, pray more, or busy themselves in other religious activity in the hopes that God will finally "get over" being mad at them. In Psalm 51, David is saying that God wants none of that. External religious activity cannot replace internal, heartfelt contrition (1 Samuel 16:7).
Psalm 51:17 points out the one thing God desires more than any other: brokenness over our own sin. When we agree with God about how bad our sin is, we take the first step toward reconciliation with Him. As long as we try to justify, excuse, or rationalize the evil of our own hearts, we never find our way back into God’s presence. Repentance is the doorway to freedom. Satan knows this and does everything he can to detract us from it. He suggests things that our selfish nature likes to hear: "Your sin wasn’t that bad." "Compared to others, you’re okay." "God has forgotten it already. No need to confess it." When we listen to the devil’s oily words, we veer away from the doorway to freedom and remain in bondage. We may feel remorse or regret, but neither is a sufficient substitute for true repentance (see Hebrews 12:17).
David reminds us that the only path to forgiveness is a broken heart and a humble spirit (cf. Matthew 5:3). When we throw ourselves on the mercy of God, He delights to lift us up (Luke 18:13-14). When we openly acknowledge our sin against God, turn from it, and cry out for cleansing, God promises that He will hear us and forgive (1 John 1:9).
It is interesting to note that, although David sinned against Bathsheba and her husband, David makes this statement to God: “Against you, you only, have I sinned and done what is evil in your sight” (Psalm 51:4). David gets to the heart of why God so hates sin. It is a violation of His very nature. We are created in that image, but our sin mars it, like a smudge on a mirror. A broken spirit and a contrite heart invite God to clean that smudge and restore us to right relationship with Him.