God and two other people show up at Abraham’s tent. Abraham offers them a feast and orders Sarah to prepare it. God promises to make Sarah a mother. Sarah laughs at this. God then tells Abraham he plans to destory Sodom and Gomorroah. Abraham asks God to have mercy and starts bargaining with him. God agrees to the bargain, if he can find just 10 good people there, he will not destroy the city.
In other words:
God sees Abraham and his wife on his way to destroy Sodom and Gomorrah.
The haggling that takes up Genesis 18:23-32. Perchance, if you won’t destroy it if you find 50 people, will you be so lenient if you find 45? Abraham negotiates the final number down to 10. It doesn’t help, but it’s fun to think of Abraham negotiating with God in this way.