Psalm 38 is identified as a “petition” of David in the superscript. This is then a prayer to the Lord for protection and deliverance that also includes the confession of sin.
Because of his own personal sin David has undergone discipline from the Lord. The discipline has effected both David’s physical health (“body,” “bones,” in 38:3; “wounds festers,” in 38:5; back pain in 38:6-7) and emotional health (“guilt” in 38:4).
This results in social rejection and the rise of David’s enemies. These enemies hope to turn this time affliction from the Lord’s divine discipline into a personal advantage since David seems very vulnerable in this situation both politically and militarily.
“My friends and companions avoid me because of my wounds;
my neighbors stay far away.
Those who want to kill me set their traps,
those who would harm me talk of my ruin;
all day long they scheme and lie.” – 38:11-12
During his time of affliction David cannot respond to his critics nor can he rise to defend himself. Because of David’s lack of response to his critics it appears that David does not even hear their arrogant and aggressive accusations:
“I have become like one who does not hear,
Whose mouth can offer no reply.” – 38:14
Thus, David seeks the Lord’s help for protection from his enemies during this phase of divine discipline. David’s only hope is in the Lord who is the very one disciplining him for his sin. David knows the Lord as both his punisher and his protector. The Lord will punish David for his sins, but the Lord will also protect David from his enemies. So, David’s only option is to “wait for” the Lord:
“Lord, I wait for you;
You will answer, Lord my God.” – 38:15
In 38:18 David willingly confesses his “iniquity” and is “troubled” by the wrongfulness of his “sin.”
“I confess my iniquity;
I am troubled by my sin.”
And, with that confession of his sin David fully expects the protection of the Lord to be manifest and the soon arrival of the Lord with his deliverance/salvation. (38:21-22)