What I love about this passage is the way in which Abraham appeals to God's better nature, as one does when one is trying to persuade someone with power to do the right thing.
Abraham's determination is quite striking, to say nothing of his skills in knowing how to approach someone in power to the best effect. Even as the men, the visitors who had arrived with the announcement that a son will be born to Abraham and Sarah, even as they turn away and head toward Sodom (to set up the dreadful events of chapter 19), Abraham remains standing before the LORD (verse 22).
The verb seems like a minor detail, but a picture begins to form: Abraham remains behind with the LORD (okay, this part of the picture is fuzzy), and then he "draws near," to say: "Will you indeed sweep away the righteous with the wicked? Suppose there are fifty righteous within the city; will you then sweep away the place and not forgive it for the fifty righteous who are in it?" (verses 23-24). The way Abraham phrases this question implies that such an action would be beneath the character of the one to whom he is speaking.
What does Abraham know of God's character at this point in the story? While God has made specific, and seemingly absurd, promises to Abraham about land and descendants, God has also promised to work blessing for all the families of the earth through Abraham's family (12:3). These re-iterated promises are basically the sum total of what Abraham knows of God's character, and it is on such a basis that he appeals to God's character as one who would not disregard the lives of the righteous even as a city faces judgment.
This question recurs throughout Israel's history and in its theological reflection. Ezekiel 18 explicitly takes it up, for example: "A child shall not suffer for the iniquity of a parent, nor a parent suffer for the iniquity of a child; the righteousness of the righteous shall be his own, and the wickedness of the wicked shall be his own" (Ezekiel 18:20). After a lengthy reflection on the justice of God, the passage concludes: "For I have no pleasure in the death of anyone, says the Lord GOD" (Ezekiel 18:32).
Yet elsewhere in Ezekiel, it seems that the innocent (though it is a real question in Ezekiel whether anyone is innocent), and even the land itself, suffer the consequences of divine judgment on the wicked (see Ezekiel 5 and 6, for example). This tension in Ezekiel is reflected within Israel's life and theology more broadly: God does not desire the death of anyone, but the empirical evidence suggests that not infrequently the innocent suffer on account of the actions and inactions of the wicked.
The explicit appeal to God's better nature appears in 18:25: "Far be it from you to do such a thing, to slay the righteous with the wicked, so that the righteous fare as the wicked! Far be that from you! Shall not the Judge of all the earth do what is just?" The expression, "far be it from..." is an idiomatic usage of the word chalil (repeated twice in the verse), which is associated with what is profane. Though it is idiomatic, the root meaning is suggestive: it would be a profanation of God's character to slay the righteous with the wicked, to be inattentive to innocence in the administration of justice.
Abraham's characterization of God as the "judge of all the earth" is interesting in the context of Genesis, which usually presents YHWH as a kind of local deity, one among other deities in the larger region. Thus, the claim is particularly bold, and canonically speaking, suggests that Abraham is making bolder, more sweeping claims about YHWH than is typical in Genesis. For Abraham everything hangs on whether this god can make good on the promises offered, and whether this god is big enough, in every imaginable way, to pull them off. He is strongly motivated to set high expectations for YHWH's character, and to appeal to those expectations directly in his encounters with God.
Thus begins the famous bargaining session between God and Abraham. God starts at fifty, if there are fifty righteous men, Sodom will not be destroyed, and Abraham gradually brings God down to ten. A subtle difference pops up in the way God speaks of the matter: in most of the chapter, God says that if a certain number of righteous persons are found in the city, God will not destroy it (verses 28-32). But the first time God speaks, after Abraham has rested his case on the basis of the righteous fifty, God does not say "I will not destroy it," but that "I will forgive the whole place for their sake" (18:26).
Apparently in the rest of the passage forgiveness of all is equated with restraint in destroying the city. Subtly introduced early in the Old Testament, then, is the idea that God can forgive whole swaths of undeserving folks, if there are but ten considered righteous. Of course, Sodom, famous for its violent disregard of the norms of hospitality (the story has nothing to do with homosexuality), cannot produce even one righteous soul to fend off destruction, and so succumbs.
This story, with its emphasis on the scope and limits of the mercy of God, might fruitfully be put in conversation with the book of Jonah, where the deep well of God's mercy to foreigners is also on display (a source of considerable irritation to Jonah). In both stories, God's desire is for a violent humanity to put an end to its violence, and if God's graceful mercy is the way to affect that, then that is infinitely preferable (perhaps ten persons are enough to turn the city around). But if, as in the case of Sodom, that is not possible, then God cares enough about the creation as a whole (for would not the rest of the world suffer if the "customs" of Sodom were to flourish?) to judge such sinfulness and to do something about it.