This is the prayer of a man who has the heart of God. David desires that God rule over the affairs of mankind so that evil ends and righteousness reigns. This is the hart of a king after God's own heart. It is a motivation that seeks the glory of God to be displayed in the world of humanity.
There were circumstances in David's life that molded him to seek this request. All his adult life he was pursued by men with evil intent bent on his destruction. It started with King Saul and never really stopped, even when David was crowned king over all of Israel. So there is a personal stake in David's request for God to end the influence of evil men. David's life was threatened, but he entrusted it into God's hands.
There is also an insight into God's unique position as Judge over humanity. God can bring justice and reward righteousness because only God can test minds and hearts righteously. That is important. God sees the heart as clearly as we know the person by sight and sound of voice. He knows our every subtle motivation much better than we will even admit to ourselves. But, even if a human COULD test the heart, no one could not do so righteously. We would still have sin taint any of our attempts at justice. But God alone is truly holy, so His evaluations of humanity are never wrong.
O God Who rightly tests our hearts, please bring evil to an end that You may establish the righteous in Your ways!