38:13-16 David paid no attention to the threats of his enemies because he believed God would vindicate him in response to his prayers. David was remarkable for his ability to wait for God (v. 15). His years of suffering at Saul's hands, his critics in Benjamin, and his treatment by Absalom had taught him to do this.
38:17-20 Evidently the psalmist felt as if he was at the end of his rope. He wanted God to respond to his calls for help very soon. David had confessed whatever sin had led to his painful condition (cf. James 5:15). He was anxious about its consequences, but there was nothing more he could do except wait for God to deliver him.
38:21-22 The psalm closes with a supplication. David pleaded with God to come to his rescue soon. The Lord had forsaken him and had stood aloof from his suffering long enough. Now it was time to save.
Sometimes believers bring physical, emotional, and interpersonal suffering on ourselves by sinning. In such cases God may discipline us with pain so we will learn not to do the same thing again. In the process we should reaffirm our trust in God as our deliverer from all our woes.