The psalm begins with a call: give thanks to the Lord, for he is good, for his steadfast love endures forever. Let the redeemed of the Lord say so, whom he redeemed from trouble and gathered in from the lands, from the east and from the west, from the north and from the south.
Then it presents four scenes with a similar pattern. In the first, some wandered in desert wastes with no way to a city, hungry and thirsty; they cried to the Lord, and he led them by a straight way to a city to dwell in. In the second, some sat in darkness and the shadow of death, prisoners in affliction and irons, because they had rebelled against the words of God; they cried out, and he broke the doors of bronze and brought them out of darkness. In the third, fools became sick through their sinful ways and drew near to the gates of death; they cried out, and he sent his word and healed them. In the fourth, those who went down to the sea in ships saw his deeds in the deep: he commanded a stormy wind that lifted the waves, and they reeled like drunken men; they cried out, and he made the storm a calm and brought them to their desired haven.
Each scene ends with the refrain of giving thanks for his steadfast love and wondrous works. Verses 33-42 show how God changes circumstances: he turns rivers into desert and desert into pools, settles the hungry and raises up the needy, while bringing the oppressors low. The last verse says that whoever is wise will attend to these things and consider the steadfast love of the Lord.