David praises God for the perspective he has based on his satisfaction in God. He compares the joy that God has produced in him with the joy others have when things go well financially. He claims that God gave him more joy than any financial prosperity could produce. That reality is what feeds into the last verse of the Psalm.
He decides to lie down and sleep because the Lord makes him to dwell in safety. David’s entire confidence is in the Lord, his satisfaction is in the Lord, his joy is in the Lord, and thus he rests in the Lord.
Hope in the Psalms
Don’t look horizontally to find peace enough to rest. Looking to your financial security might bring rest for a while, but eventually, the worry that money brings with it will overtake the peace it brought. Look to God as the center of life and joy, rest and peace will be the result (Nehemiah 8:10).