Why did HaSh-m say "Lo Ash'chis" regarding 45; "Lo E'eseh" regarding 40 and 30; and again "Lo Ash'chis" regarding 20 and 10?
Da'as Zekenim, Hadar Zekenim, Rosh (to 18:32): If there are 10 Tzadikim in every city, I will not punish at all. If there are nine and I must join Myself, I will not destroy, but I will afflict. If there are 10 in each of three or four cities (the majority), I will not punish at all [even the cities without Tzadikim]. If there are 10 Tzadikim in each of one or two cities (the minority), I will not destroy, but I will afflict.
Moshav Zekenim (to 18 23): First HaSh-m said that He will not destroy [even] the Resha'im (if there are at least 45 Tzadikim). Later, He said that He will not do [only] to the Tzadikim (but He will destroy the Resha'im). 1 '
Seforno: Even if I must join Myself to each city, I will not destroy the worst city of the five. If three or four cities (the majority) are worthy, I will not punish them at all, only the other cities. If only one or two cities are worthy, I will not destroy them, but I will bring upon them suffering. 2
Why did Avraham ask for 40, 30, 20 and 10?
Rashi: If there are 10 in each of four cities, those cities should be spared, and similarly for three, two and one.
Moshav Zekenim: All his requests were to save all five cities. 1
Also refer to 19:21:151:1.
QUESTIONS ON RASHI
Rashi writes: "'Perhaps forty [righteous] will be found there' - and thus rescue four of the cities." Avraham has already been told that fifty would save five cities; why did he need to pray again for the same ratio?
Ramban: A large number of people serving G-d is qualitatively better than a small amount. Avraham could not take for granted that forty would be effective at all, and so he asked again.
Gur Aryeh: The verse uses the pronoun, "found there," referring to Sedom itself (to which the other cities were secondary). Perhaps the 40 righteous were found in the other cities, and not in Sedom? Gur Aryeh explains (unlike Rashi) that Avraham was still requesting the salvation of all five cites, 1 and that 40 righteous (combined, enough for four cities) should be sufficient to tip the balance for all five of them. He then asked for 30, etc..
Moshav Zekeinim writes this as well; refer to 18:29:152:2.