The purpose of judgment is to turn or remove the wicked, so that righteousness can be restored.
God is telling them: I am going to restore your judges and redeem Zion. Jerusalem will be known as a righteous and faithful city. You can be part of that. If not, I will not only destroy my enemies, I will turn against you too.