Have you not read in the Law of Moses that every Sabbath the priest in the Temple actually break the Sabbath law, yet they are not guilty? Matthew 12:5
The Pharisees seeing the disciples of Jesus being hungry, began to pick of corn and eat the grain while walking through said it was against the Law to do on the Sabbath.
Jesus said that even David and his men when hungry ate the bread offered to God in the house of God. The priests themselves were actually breaking the Sabbath law every Sabbath for what they were doing while offering sacrifices. Yet, why were they not guilty of doing such? ” I tell you that there is something here greater than the Temple, if you really knew what this means, you would not condemn people who are not guilty; for the Son of Man is Lord of the Sabbath. ”
King David, although he was guilty of adultery and murder, he repented and confessed his sin heartedly. He expressed himself and prayed for forgiveness in his Psalm.
He recognized his faults for what he did which was evil in the eyes of God. He begged God to remove his sin to cleanse him. In his mercy, God once again created a pure heart and put a new and loyal Spirit in David after, which he was spoken of a man after God’s heart. Acts 13:22.
Knowing your guilt is pleasing to God.