David here tells us what he had experienced, 1. Of the temptations of a prosperous condition: “Before I was afflicted, while I lived in peace and plenty, and knew no sorrow, I went astray from God and my duty.” Sin is going astray; and we are most apt to wander from God when we are easy and think ourselves at home in the world. Prosperity is the unhappy occasion of much iniquity; it makes people conceited of themselves, indulgent of the flesh, forgetful of God, in love with the world, and deaf to the reproofs of the word. See Ps. 30:6. It is good for us, when we are afflicted, to remember how and wherein we went astray before we were afflicted, that we may answer the end of the affliction. 2. Of the benefit of an afflicted state: “Now have I kept thy word, and so have been recovered from my wanderings.” God often makes use of afflictions as a means to reduce those to himself who have wandered from him. Sanctified afflictions humble us for sin and show us the vanity of the world; they soften the heart, and open the ear to discipline. The prodigal’s distress brought him to himself first and then to his father.