Bereshit / Genesis 18:25 · Sod
חָלִלָה לְּךָ מֵעֲשֹׂת כַּדָּבָר הַזֶּה לְהָמִית צַדִּיק עִם־רָשָׁע וְהָיָה כַצַּדִּיק כָּרָשָׁע חָלִלָה לָּךְ הֲשֹׁפֵט כָּל־הָאָרֶץ לֹא יַעֲשֶׂה מִשְׁפָּט׃
Far be it from You to do such a thing, to put the righteous to death with the wicked, so that the righteous should be like the wicked. Far be it from You! Shall the Judge of all the earth not do justice?"
Sod סוֹד
Five hundred to one
Avraham fears that "the righteous will be like the wicked". A Chasidic teacher asks: why can the righteous save the wicked, while the wicked cannot bring down the righteous?
Be'er Mayim Chaim: the measure of good is five hundred times greater than the measure of punishment. So the merit of the righteous covers the wicked, while the sin of the wicked does not drag down the righteous. Judgement goes by stages: first the country, then the city, then each person. And the righteous will not die with the wicked.
How Be'er Mayim Chaim explain it
Be'er Mayim Chaim So that the righteous should be like the wicked
So that the righteous and the wicked would have one measure. For in a good time, when the righteous prevail and their deeds outnumber the deeds of the wicked, their merit protects the wicked too. And great are the righteous who turn the attribute of judgement into mercy, and the wicked are saved with them in their merit. And if it were so with the measure of the wicked too: when they prevail, the righteous perish with them, "He destroys the whole and the wicked" (Iyov / Job 9:22), then "the righteous would be like the wicked", in equal scales. But it is not so: the measure of good is greater than the measure of punishment five hundred times, as stated in Tosafot (Sotah 11a) in the name of the Tosefta.
Be'er Mayim Chaim Shall the Judge of all the earth not do justice
Explanation. It is known from the words of the Rambam (Laws of Repentance 3:1) that the Holy One, blessed is He, judges and weighs a country as a whole, whether its merits or its sins are more, and so each city, and so each individual. And Avraham argued that the measure should be thus: first the country is judged as a whole, and if the country has more merits, the whole country is saved, the wicked with the righteous, in their merit. And if it has more sins, then each city is judged, and a city with more merits is saved entirely. And if not, each one is judged alone, and whoever is righteous will be saved, and the righteous will not die with the wicked.
This is "shall the Judge of all the earth not do justice?" That is, because You judge the whole earth as a whole, will You not do justice and put to death the righteous in it when it has more sins? Not so: You will save the righteous. And the weighing helps only when merits are more: then the wicked are saved in the merit of the righteous, and not the reverse. For the measure of good is greater than the measure of punishment five hundred times, as said above.
Takeaway
Rambam, Laws of Repentance 3:1–2: a person, a city and a country are judged by what is more in them, merits or sins.
The Sages draw five hundred to one from Shemot / Exodus 20:5–6: punishment "to the third and fourth generation", but kindness "to thousands" (Tosefta Sotah 4:1).
Be'er Mayim Chaim is the book of Rabbi Chaim of Czernowitz, an 18th-century Chasidic teacher.