This psalm begins with a command for the redeemed of the Lord to "Give thanks to the Lord, for He is good, His love endures forever." The psalmist gives us four examples of people who were in dire circumstances for different reasons. Some were simply lost. Some were rebellious and fell into bondage. Some lost their minds because of their pursuit of their own pleasure. Some found themselves in danger because of natural disasters. All of these people, when they had no other help, cried to the Lord. And He Heard Them! He answered their cry for help!
At the end of the psalm, we are given a brief picture of God disciplining those who are rebellious, while still caring for those who are poor and downtrodden. Remember that the previous stories told of those who had trials because of their own rebellion and bad choices, and when they called, God answered them as well as those who came on hard times through no fault of their own. God may bring about hard times in our lives in order to get our attention. He may allow us to suffer the natural consequences of our actions. But when we call to Him, He forgives and will answer our cry for help.
Closing the psalm, the psalmist tells us to consider the way that God's love works out in our lives. He says those who are in good standing with God will rejoice to see Him at work. And those who are not in good standing with God will shut their mouths. We, then, have a choice. We can be wise and ponder God's acts on our behalf, which leads to rejoicing. Or we can choose to set aside thoughts of God at work, and find ourselves with nothing to say.