Let me start here by giving an explanation of two specific words used here: The word “land” refers to Israel. The “city of the LORD” refers to Jerusalem from where David ruled. So does this verse tell us that David literally had police going around killing anyone who was wicked while He was king?
The Bible records that David did have rebellion issues while he was king and he depended on God to deal with such rebellion. The point of this “coronation speech” is that it was David’s desire to always do what he believed God desired. David wanted to prevent anyone who didn’t trust in God to not have any sort of power in a country that was supposed to live under His authority.
As believers, we should remember to pray for our leaders. We ought to pray for them to do the right things as well as to avoid what is sinful. Should I pray for our leaders to kill all evil people? I don't think that is literally possible.
Rather, we should pray for those in power to stop those who do harm to society and bring justice to this world. If you recall, the first verse of this Psalm was a call for God’s justice as well as His love. Justice is a desire to bring closure to crimes and even sins that were committed. Grant it, not all people get caught in this lifetime, which is another reason why we believe in a God who will judge all things.
Just because we believe God will “right the wrongs" of the world one day, this does not mean we as a society should not make every effort to do our best to deal with problems in our lives. Sometimes justice does happen and sometimes it does not. That should never stop us from doing the right thing and praying for justice.