This is a classic psalm of lament. From beginning to near the end the Psalmist is calling out to the Lord because he is in over his head in trouble and imminent danger. The transition takes place starting in vs. 30 and then in vs.33 we find that “the Lord hears the needy, and does not despise his own that are in bonds.” The assumption is that the writer would fill both of those categories as being needy and belonging to the Lord.
So much of this psalm is the author stating that he did what was right and what was expected of him and yet people still mocked and made fun of him. He fasted and they insulted him (vs.10). We find vs.9 as a verse which is repeated when Jesus drives out the money changers from the temple in John 2:17. Being consumed with zeal for the house of the Lord is a good thing, even if it does lead to some social separation. Doing what is right is no guarantee that we will have favor on this earth. It is a common misconception that as we become followers of Jesus Christ then our lives become a bit more routine and able to be managed. I would actually argue quite the opposite. The more we belong to Christ, the less steady we are on this earth. That is also a good thing.