There's a story in the Bible where Abraham barters with God about sparing those two cities.Abraham asks God to spare those cities if 50 righteous people were found there, then 45, then 30, then 20 or even 10 and God agrees not destroy them after each request, for the sake of the righteous in those cities.

The question remains:Righteous according to whose standards? If God says "I won't wreck those places if people are as righteous as I am" then of course they're destroyed...maybe Abraham has a more forgiving nature and isn't so much of a tough rules kinda guy.