Truly God is good to Israel, even to such as are of a clean heart.
A clean heart — To all true Israelites, who love God, and serve him in spirit and truth.
 But as for me, my feet were almost gone; my steps had well nigh slipped.
My feet — My faith in God's providence, was almost overthrown.
 For there are no bands in their death: but their strength is firm.
No bands — They are not dragged to death, by the sentence of the magistrate, which they deserve.
 They are not in trouble as other men; neither are they plagued like other men.
As other men — As good men frequently are.
 They are corrupt, and speak wickedly concerning oppression: they speak loftily.
And speak — Boasting of their oppressions.
 They set their mouth against the heavens, and their tongue walketh through the earth.
Against — Against God, blaspheming his name, and deriding his providence.
Walketh — Using all manner of liberty, reproaching all sorts of persons.
 Therefore his people return hither: and waters of a full cup are wrung out to them.
Turn — To this wicked company.
Waters — And partake of the same prosperity with their leaders. God seems to give them a full cup of consolation, as if he would wring out all his blessings upon them.
 Behold, these are the ungodly, who prosper in the world; they increase in riches.
Behold — These seem to be the words of the psalmist, summing up the matter.
 Verily I have cleansed my heart in vain, and washed my hands in innocency.
In vain — Hence I was sometimes tempted, to think that religion was a vain, unprofitable thing. True religion is here described by its two principal parts, the cleansing of the heart, and the hands.
 If I say, I will speak thus; behold, I should offend against the generation of thy children.
Offend — By grieving, discouraging and tempting them to revolt from God.
 When I thought to know this, it was too painful for me;
To know — To find out the reason of this providence.
 Until I went into the sanctuary of God; then understood I their end.
Until — 'Till I consulted the word of God. He alludes to the practice of those times, which was, in difficult cases to resort to God's sanctuary, and the oracle therein.
Their end — There I learned that their prosperity was short.
 How are they brought into desolation, as in a moment! they are utterly consumed with terrors.
Terrors — With God's dreadful judgements unexpectedly seizing upon them.
 As a dream when one awaketh; so, O Lord, when thou awakest, thou shalt despise their image.
They awake — Out of the pleasant dream of this vain life.
Despise — Thou shalt make them despicable both to themselves and to all others; raise them to shame, and everlasting contempt.
Image — All their felicity and glory, which shall be evidently discerned to be, no real or substantial thing, but a mere image or shadow.
 Thus my heart was grieved, and I was pricked in my reins.
Pricked — I was deeply wounded with disquieting thoughts.
 So foolish was I, and ignorant: I was as a beast before thee.
Nevertheless — Although I gave thee just cause to cast me off, yet thou didst continue thy care and kindness to me.
Hast held — That my faith might not fail.
 For, lo, they that are far from thee shall perish: thou hast destroyed all them that go a whoring from thee.
Go a whoring — Those who revolt from thee, to work wickedness; which is called whoredom in scripture.