This is a psalm of Asaph (a musician on the Temple)
In the beginning of Psalm 73, Asaph envies prosperity of those who were wicked. He envies their lives that seemed to not be troubled or or have problems. He goes on to say they are like “fat cats” who have everything their heart could wish for. (v.7) NLT
Then Asap figures it out. “So I tried to understand why the wicked prosper. But what a difficult task it is! Then I went into Your sanctuary, O God, and I finally understood the destiny of the wicked. Truly, You put them on a slippery path and send them sliding over the cliff to destruction. In an instant they are destroyed, completely swept away by terrors. When You arise, O Lord, You will laugh at their silly ideas as a person laughs at dreams in the morning.
Then I realized why my heart was bitter and was only torn up inside . I was so foolish and ignorant – I must have seemed like a senseless animal to You. Yet still I belong to You: You hold my right hand. You guide me with Your counsel, leading to a glorious destiny.
Whom have I in heaven but You? Desire You more than anything on earth. My health may fail, and my spirit may grow weak, but God remains the strength of my heart; He is mine forever.
Those who desert Him will perish, for You destroy those who abandon You. But as for me, how good it is to be near God! I have made the Sovereign Lord my shelter, and I will tell everyone about the wonderful things You do.” (vv. 16-28) NLT