You do not delight in sacrifice, or I would bring it;
you do not take pleasure in burnt offerings.
The sacrifices of God are a broken spirit;
a broken and contrite heart,
O God, you will not despise.
In your good pleasure make Zion prosper;
build up the walls of Jerusalem.
Then there will be righteous sacrifices,
whole burnt offerings to delight you;
then bulls will be offered on your altar.
-- Ps. 51
David here realizes one of the most interesting paradoxes of the life Christian.
On the one hand, he realizes that God doesn't care about the outward acts that signify religious obedience. He knows that these are the very mandates that God gave the Israelites, yet he realizes that these sacrifices are not the heart of the matter. The heart of the matter is the state of his heart.
By the end of the Psalm, he is talking again about the same sacrifices and offerings he was decrying just a few verses earlier, but now he speaks of how they will delight God. What changed? His heart: broken and contrite. A changed heart drives him to make these sacrifices and offerings despite the fact that he's already ascertained that they are not what God is really looking for.
David realized that the act of sacrifice is one done out of love - either love of self or love of God. The original sacrifices he spoke of were being made to please God, but not out of love for Him - instead they were being made out of love for self - sacrifices made in order to get something back from God. But a contrite heart is one that's in a state to truly sacrifice in love - to give while expecting and hoping for nothing in return. That's how true, selfless love gives.
In the end, sacrifice in David's day was a true means of grace. In our day, it is still something God seeks from us. But He will never be pleased in sacrifice made with selfish motives. He wants nothing less than the whole heart, broken though it may be.