HO? God. How? Sovereign Providence. Why? Because He is holy. Wait, what are we even talking about here? Well, Asaph wrote this psalm of gratitude and worship expressing his worshipful attitude toward God for the way that He handles humankind. So, in this context there are a few understood questions. Here they are in reverse order. Why do men of influence and authority have their positions? How do they rise to their places of power? And, who is the mover and shaker behind it all?
There are a couple of entities whom Asaph introduces right off - the congregation (the assembly or "the masses") and judges (people in positions of power). From the time of Noah's flood on up until now, God has been giving certain men authority over their peers. The purpose is simple. God intends for kings, presidents, mayors, police officers, judges, etc. to utilize their "sword" for the promotion of justice (Romans 13:4). God intends for the quick execution of fair judgment to both rid society of its worst elements and also to motivate those remaining to avoid vices. Ultimately though, the purpose of human authority is to point people's attention toward their Maker and Judge. (Psalm 75:7).