While Psalm 38 has traditionally been categorized as a penitential Psalm, it is more of a lamenting prayer. David is crying out with words and sighs for relief from his physical affliction, emotional anguish, and ensuant isolation. The penitential aspect of the Psalm is evident in how David understands his trial to be a consequence of personal sin. He refers to "my iniquities" (v. 4), "my foolishness" (v. 5), "my iniquity," "my sin" (v. 18). Not every trial is the result of sin, however; this fact is clear in verse 20, where David prays: "Those who render me evil for good accuse me because I follow after good."
Psalm 38 teaches us that we are not alone in our trials; our emotions under pain and suffering are important to God, even if we have brought things upon ourselves through our sin. God would never tell His child: "you made your bed, now lie in it." Instead, He hears the prayers of sinners (contrary to the opinion of the Pharisees who announced: We know that God does not listen to sinners, but if anyone is a worshiper of God and does his will, God listens to him – John 9:31). By the end of the Psalm, David is assured that God will not forsake him, but will draw near to, help, and save him.