This is challenging on two levels. First, why should Avraham assume that God, who is the Lord of Justice, has not already determined there are no (or are an insufficeint) number of righteous people in Sodom? Second, and more important, if it is unjust for God to slay the righteous with the wicked, how do we explain the world around us? Heck, we have two full books of the Tanach that wrestle with the question of why the righteous suffer and the wicked prosper. Certainly in calamities such as the Holocaust or even natural disasters like Katrina, the righteous perish with the wicked. Is this the Lord of Justice not doing that which is just? Alternatively, if God is just despite these actions, how can Avraham question God's decision to destroy Sodom, even if some innocents are also destroyed?
I propose the following answer. Usually, God works through derech hateva -- the means of nature. In these processes, God acts in unfathomable ways that are not amenable to human comprehension. Our primitive notion of basic quid pro quo of so many "virtue points" balanced against so many "sin points" cannot begin to cqapture the complexity of God's intent. Inn such circumstacnes, to presume that we can judge how a natural calamity, or even a man-made calamity such as a war, is an expression of God's direct decisions pertaining to every individual in the World is absurd. We, as human beings, cannot begin to know the mutli-shifting calculations and how something that we see as a "punishment" or a "reward" may serve other purposes.
But here, God explicitly revelas to Avraham that the "Cry of Sodom" has reached him and that therefore God will violate the natural course of events and directly punish Sodom. In this instance, there is no doubt of God's handiwork or why. Indeed, the Midrash tells us that God was at great pains to destroy the city when both the sun and Moon were in the sky, so that people could not claim that it was some influence other than God that destroyed Sodom.
In such a case, the regular rules do not apply. If God is so dramaticly altering the natural course of the world, then there is no need for neat and unfathomable calculations. Only total complicity of the population in such sin can justify the total destruction of Sodom.
Avraham, moved by compassion, therefore asks God if it can really be true that there are not even 50 good people who can "save the city." Of course, God could save the good people directly, but in such a case Avraham would presume that God would work through natural means. Because such dramatic and collective punishment has only occurred twice in the world (Flood, Bavel) and then only when the entire population was engaged in wickedness.
Hence Avraham's argument with God. It may be that you intend to save the individual righteous people, says Avraham, but it cannot be just destroy the entire city by miraculous means if there are a sufficient number of good people to save it.