1st of all, the presumption of the question is that the "Great City" is Jerusalem. In a poll of commentators, about half agree that it is Jerusalem, and the other half see it as an extension of Babylon/Rome. Matthew Poole's Commentary states,
Some, by the great city, would have Jerusalem understood; but that
was now far from a great city, nor do the addition of those words in
the latter end of the verse prove it; for Christ was not crucified in
that city, but without the gates. Most judicious interpreters, by the
great city here, understand Rome, which is seven or eight times (under
the name of Babylon) so called in this book.(Taken from here)
Other commentators, such as Ellicott, give this explanation,
The city is described as the great city (comp. Revelation 16:19), and
also as Sodom, Egypt, and Jerusalem. Do not passages like this show
conclusively that to deny the mystical or allegorical sense of the
Apocalypse is to keep the husk and cast away the seed? The city is
great, for it is all-important in the eyes of the inhabitants, as
public opinion is all-important to the weak or the worldly; it is
Sodom, for it is the place where, through pleasure and luxuriousness
(fulness of bread), the worst forms of immorality take root; it is
Egypt, for it is the house of bondage, where the wages of sin become
tyrannous; it is Jerusalem, for it is the apostate place where the
presence of Christ is hated.(Taken from here)
Both commentators give compelling reasons: Jerusalem is certainly the scene of the Lord's crucifixion, that fact that it was 'outside the city proper' does not negate the fact that it began within the city, and indeed, the actual event taking place outside the city fulfills Scriptural precedent,(Heb. 13:12-13)
" Wherefore Jesus also, that he might sanctify the people with his own
blood, suffered without the gate.
13 Let us go forth therefore unto him without the camp, bearing his
reproach."
This passage is in reference to Lev. 24:14,
Bring forth him that hath cursed without the camp; and let all that
heard him lay their hands upon his head, and let all the congregation
stone him.
Jesus bore the curse for all sin outside the camp; since the Temple was permanently in Jerusalem, the precedent was that we would go 'outside' Jerusalem a short distance, that the sin could be taken 'outside' and the camp/city be healed. Jesus Himself said,
(Luke 13:33)
Nevertheless I must walk to day, and to morrow, and the day following:
for it cannot be that a prophet perish out of Jerusalem.
The question that has divided the commentators, and the subject of our discussion is:
"How can Jerusalem be both the "City of the Great King" and "Sodom and Egypt"?
What must 1st be noted is that the deaths of Jesus; the prophets that preceded Him, nor the Apostles that followed Him, up to the deaths of the 2 witnesses did not cleanse the city. There is no question that Jerusalem was to reflect the glory of God,(Jer. 3:17)
At that time they shall call Jerusalem the throne of the LORD; and all
the nations shall be gathered unto it, to the name of the LORD, to
Jerusalem: neither shall they walk any more after the imagination of
their evil heart.
This is "The City", the "Great City" that rules over all the kingdoms of the earth. However, in killing the prophets, as well as those who bring testimony of Jesus to it, Jesus says,(Matt. 23:37-39)
O Jerusalem, Jerusalem, thou that killest the prophets, and stonest
them which are sent unto thee, how often would I have gathered thy
children together, even as a hen gathereth her chickens under her
wings, and ye would not! Behold, your house is left unto you desolate.
For I say unto you, Ye shall not see me henceforth, till ye shall
say, Blessed is he that cometh in the name of the Lord.
Sodom and Egypt fell under the Lord's judgment; Sodom for all eternity and Egypt under numerous times. Jerusalem had incurred God's wrath in the same manner as Sodom and Egypt, as she had participated in the sins both were guilty of; hence figuratively she could be called the same as them. The difference is "til"(Matt. 23:39)God's favor for Jerusalem goes beyond their sinfulness; when she says, "Blessed is He who comes in the name of the Lord",then she becomes the "Joy of the Whole Earth" and the City that reigns over all the earth.