This psalm describes how sin leads to unhappiness but forgiveness restores joy. It says:
1) Keeping sin secret makes one waste away in grief, but confessing sin to God brings forgiveness and relief from guilt.
2) The righteous should pray to God especially during troubles, for God protects them from harm.
3) God instructs the righteous in the right path and shields them from sorrow, while the wicked face many troubles.