David knew that God alone can make the heart clean and pure. He knew that sin separated him from the presence of God. And he knew the joy of salvation is preceded by repentance.
Nothing pleases the Lord more than obedience. Elsewhere in scripture it says to obey is better than sacrifice. Here God is pleased with a brokenness over sin and a contrite and humble heart!
Examine your life: is obedience the norm of rebellion? Are you tender and teachable when the Spirit convicts or do you ignore and so harden yourself?