Psalms 73:21

Thus my heart was grieved, and I was pricked in my reins.

The verse is David's confession of a grieved heart and inward pricking of conscience after he had judged God's ways as unequal. His distress had grown from envy toward the foolish when he looked at the prosperity of the wicked. He saw them possessing firm strength, with no bands in death, with no trouble as other men have, and increasing in riches, while those who truly love God are compassed about with difficulties and perplexities.

He could not understand this contrast until he went into the sanctuary of God, where he understood their end. That end is that God sets the wicked in slippery places and casts them down into sudden desolation and terrors. When he saw this, his heart was grieved and pricked within, and he acknowledged that he had been foolish and ignorant, like a beast before God. Even so, he was continually with God and upheld, held by His right hand. Through this he learned that it is good to draw near to God and to put trust in the Lord God.