God destroys Sodom and Gomorrah, Lot lives with his daughters, Abraham lies to Abimelech about Sarah, and Isaac is born: Genesis 18–21
The prophet Amos tells us that the Sovereign Lord never does anything until he reveals his plans to his servants the prophets Amos 3:7, and we get to see some of the reasoning here in relation to the intended destruction of Sodom and Gomorrah:
Genesis 18:17-19 Should I hide my plan from Abraham? … For Abraham will certainly become a great and mighty nation, and all the nations of the earth will be blessed through him. I have singled him out so that he will direct his sons and their families to keep the way of the Lord by doing what is right and just. Then I will do for Abraham all that I have promised.
The idea of teaching Abraham about doing what is right and just was more than just a case of dealing with the sin itself, which was displayed openly, as is evident from the original narrative in Genesis and as Isaiah (3:9) said centuries later. God could have just destroyed those two cities, no one would have been any the wiser today.
The reason for telling Abraham was to show him and others the consequences of sin:
1 Peter 2:6 Later, God condemned the cities of Sodom and Gomorrah and turned them into heaps of ashes. He made them an example of what will happen to ungodly people.
But it was more than that, too.
It also about showing Abraham his own response to God’s impending judgement on another. The response was impressive. Rather than rejoicing in their doom, Abraham sought their relief and bargained God down: would God spare the cities for the sake of only 50, then 45, then 30, then 20 and finally only ten righteous people? If ten had repented of their sin, would God have withheld judgement? The answer appears to be yes:
Genesis 18:32And the Lord replied, ‘Then I will not destroy it for the sake of the ten [righteous people].’
Since only Lot and his immediate family were evacuated, most people assume they were the only righteous people to be found.