The second question above that is the only one that we should focus on; but answers may still be hard to find.
The story seems to tell us that God was on His way to judge the evil of the cities and “happened” to pass by Abraham. Abraham has to ask them to stop. It is then, around a meal, that God mentions the prophecy He had already revealed to Abraham. This time around Sarah hears it. But it is after dinner, once the angels of judgement are already on their way, that God informs Abraham of His plans. His reasons for doing so are interesting:
“…since Abraham will surely become a great nation, and in him all the nations of the earth will be blessed? For I have chosen him, so that he may command his children and his household after him to keep the way of the YHWH by doing righteousness and justice, so that the YHWH may bring upon Abraham what He has spoken about him.”
God seems to have a dual purpose in revealing His plans to Abraham.
First, we see that God wants to impress upon Abraham the seriousness of sin against God’s holiness. God cannot abide the sin in His creation. In Sodom and Gomorrah’s case, the sin has reached a level of crisis. God is preparing to closely examine the people there, and see if the level is as dire as the “outcry” indicates. In Abraham’s story—the story of Scripture—we see that God is on mission to redeem creation from humanity’s sin; but we are also reminded that God’s justice is complete. We will come again and again to this lesson, God is merciful and gracious, but He will always remain just and will not tolerate sin. (See also 15:16 as it relates to the taking of the Promised Land in Judges.) God wants Abraham (and his descendants, both physical and spiritual) to learn the seriousness of this issue.
But God also wants Abraham (and his descendants) to partner with Him in His mission. Abraham does not just receive the news of coming judgement silently. He begins to bargain with God for the sake of potential redeemable people. This is a prayer for God to be true to His justice. The wicked must be judged, but what about the righteous? It is also an appeal to God’s mercy and grace. If a small fraction of redeemable people exist, can the city remain?
The prayer does not change events. God knew already what would be found in the cities. He did not tell Abraham in hopes that Abraham would persuade God to change. But the prayer does change Abraham and us as readers of this event. We see that God is indeed prepared to be merciful for the sake of a tiny remnant. A mere ten people would have spared the city. Later on we see that Israel itself is granted mercy in is sin, thanks to a tiny fraction of the people who remain true to YHWH. (1 Kings 19:18, and others)
God holds creation and His mission in His perfectly sovereign plans. He knows what He is doing, and He always acts in perfect love, mercy, and grace alongside perfect holiness and justice. However, He gives us glimpses of His plans and activity so that we can come alongside Him in His efforts to redeem His creation. So that we can have the opportunity to change and align ourselves ever more with His plans. We can pray with boldness as Abraham did, confident that God will do what is best, but also attentive to what we can learn through the things God shows us.