Psalm 32's title says it is By David, a contemplative psalm. It opens with a double blessing: Blessed is he whose disobedience is forgiven, whose sin is covered. Blessed is the man to whom Yahweh doesn't impute iniquity, in whose spirit there is no deceit. To impute is to count against someone. In the New Testament, Paul quotes these lines to show that God counts people righteous through faith, not by their works (Romans 4:6-8).
Next David tells his own story. When he kept silence about his sin, his bones wasted away through his groaning all day long. For day and night your hand was heavy on me. His strength was sapped as in the heat of summer. Unconfessed sin weighed on body and soul. The turning point is verse 5: I acknowledged my sin to you. I didn't hide my iniquity. I said, I will confess my transgressions to Yahweh, and you forgave the iniquity of my sin. Confession led straight to forgiveness. So David urges every godly person to pray while God may be found. You are my hiding place. You will surround me with songs of deliverance.
Then God himself seems to speak: I will instruct you and teach you in the way which you shall go. I will counsel you with my eye on you. Don't be like the horse, or like the mule, which have no understanding and must be controlled by bit and bridle. God wants willing followers, not stubborn ones. The psalm ends, Many sorrows come to the wicked, but loving kindness shall surround him who trusts in Yahweh. Be glad in Yahweh, and rejoice, you righteous! Shout for joy, all you who are upright in heart!