The Alshich gives a nice explanation. Every wicked ruler that oppressed us was predicted in a prophecy ahead of time, with the intention that they would oppress us because of our sins, and in so doing, His name would be glorified. This means that indeed He created these wicked people for a purpose. Note, that these people are still to be considered wicked, not righteous, even though they have been sent by Hashem to destroy the sinners of Israel.
I have heard explanations that this is because they didn't do their mission of punishing the Jews lishma, and often went way too far.
There's also the point that leaders have their free will removed. So therefore it is right to call them evil. They are agents of destruction and oppression, just like some angels and even the evil inclination, and all of these are called "evil", even though they don't have free will.
tl;dr: the wicked referred to here are the leaders of nations who came to oppress Israel, like Pharaoh, Titus and Nevuchadnezzar. They were created to do this evil mission by Hashem, to glorify His name when He punishes Israel for sin.