Psalms 38 and 39 have at least one thing in common: they are written by someone who is suffering, he feels, at the hand of God. The suffering is not unwarranted. The writer does not deny his sin, nor that he deserves discipline. Psalm 40 differs slightly in that while the writer is also suffering because of sin, the “punishment” is simply the consequences of sin. His plea is simply that God will shorten the time of punishment.
Psalm 39 was written “for” Jeduthun. The most prominent person with that name in the Old Testament was a lead musician in David’s court, under David’s direct supervision (1 Chronicles 25:6) and I wonder whether the Psalm was written as a prayer for him to pray during a time of distress, or if it was a poem of instruction.
Either way, the main points will be the same: time has been wasted. Sin has been committed. Wealth has been lost as a result, and the subject knows it is his own fault – a judgment from God. He asks God to help him use his time wisely, and he requests that God “look away from me” – not that God no longer care about him, but that God shorten the punishment and restore his life.
Whether difficult days are the consequence of behavior or a deliberate additional punishment, it is the wise person who recognizes the hand of God and turns to the Lord for redemption.