David may have written this psalm also. In fact, he may have written all those listed as a song for pilgrims. In 2 Samuel 6, we read of David’s ascending to Jerusalem as he moved the Ark of the Covenant to its new home where it remained for about 400 years. Thoughts of that event may have inspired him to write psalms encouraging other pilgrims in their quest to worship the one true God.
In verses 1 and 2, he wrote about the security of the believer using Jerusalem on Mount Zion as an example. In David’s day, Jerusalem and Mount Zion were one. They were surrounded by a large wall that could resist any army of his day. In fact, it wasn’t until 606 B.C. that the Babylonian army was the first to conquer the city. God quit defending the city and allowed it to be captured because of Judah’s sin and idolatry.
“The wicked will not rule the land of the good, for then the godly might be tempted to do wrong.” (Verse 3) It took 400 years before Judah became so wicked God turned them over to the Babylonians. It began with Solomon who in his later years turned to worshipping his pagan wives’ idols. Gradually David’s descendants continued to wander from God. One example is King Ahaz who had a godly grandfather and father, but who introduced idolatry in Jerusalem even in the Temple. (2 Kings 16)
A second example is King Manasseh whose father was Hezekiah, the son of Ahaz. Hezekiah got rid of all the idols his father had provided. Manasseh went in the opposite direction and led Judah into more idolatry than any other king. He was so bad God allowed him to be carried off into Assyrian captivity in prison until he repented. (2 Kings 21:1-18; 2 Chron 33:1-20) While he changed things after being restored to the throne, the Scriptures still blamed his sin for the Babylonian Captivity because of its effect on the people of Judah.
David asked for two separate outcomes in verses 4 and 5. First, he prayed, “O Lord, do good to those who are good, whose hearts are in tune with You. . .May Israel have peace.” Second, he prayed, “But banish those who turn to crooked ways, O Lord. Take them away with those who do evil.” David wasn’t praying for their damnation; he was only praying for their departure that Israel would have peace. I have often thought there are three reasons God takes believers home; we have either learned all He wants us to learn or done all He wanted us to do or we are so willful He couldn’t do anything else with us. I am thankful I am still here.