First of all who is speaking in the Psalm? It is David.
David is a man and like all men his sentiments can be misleading. He had committed evil but not to God.
Bear in mind that the old testament was written before the truth became known. Or was even in the world.
The truth that was Jesus. His character, decisions, actions all displayed the Father’s attitude and if David had known Jesus he wouldn’t have felt guilty before God.
Jesus who came for the sinners. Who hung around with sluts and drunkards, who was friends with them AND tax-collectors!
Do you think they would have enjoyed his company, sought Him out if He’d always been condemning them?
No! Of course not.
There was one group that Jesus condemned vigorously though. The religious elite.
In fact I don’t recall ever reading an account in which Jesus got angry or even rebuked someone for being drunk or committing adultery.
Look at the samaritan woman, the way He used His knowledge of her adultery to befriend her and give her and her town the Good News.
“the law was given by ,Moses, but grace and truth came by Jesus Christ” John 1:17
That means that the law was not the truth nor was the truth in it. The law’s purpose was to bring everybody into condemnation.
“Now if the ministry of death, carved in letters on stone, came with such glory that the Israelites could not gaze at Moses’ face because of its glory, which was being brought to an end, will not the ministry of the Spirit have even more glory?
For if there was glory in the ministry of condemnation, the ministry of righteousness must far exceed it in glory.
Indeed, in this case, what once had glory has come to have no glory at all, because of the glory that surpasses it.
For if what was being brought to an end came with glory, much more will what is permanent have glory.” 2 Corinthians 3: 7 – 11
That condemnation/guilt is what David is expressing here. But it is not the truth concerning God’s attitude towards David.
In fact it is the death that man died the day he ate of the tree gaining knowledge of his own inadequate, impotent and awkward self in the light of the fullness that is the Father.
Man experienced shame for the first time when they ate of the tree.