The city of Sodom is encountered three times during the story of Avraham. The first time is when Lot decides to take up residence there. Already then, the Torah reports that "the people of Sodom were very wicked sinners before God". The second time is during the war of the four kings against the five kings, where Avraham rescues the people of Sodom and returns them to its king. Finally, in next week's parsha, the city of Sodom is destroyed as punishment for its wickedness.
Why the wait? Sodom was wicked from the start; what happened between the first encounter, when Sodom is already wicked, and the third, when it is destroyed? The second encounter, of course.
In the second encounter, the King of Sodom meets Avraham. Their meeting is very awkwardly broken up by the apparently simultaneous meeting between Avraham and Malkitzedek. I think that the key to understanding Sodom's destruction lies in this encounter.
Avraham had just won a decisive battle. The people of Sodom had been captured and enslaved, and Avrhaham had come into possession of them and their belongings. And he gives it all back. he was entitled to the property and even the people, as the verses make clear. In fact, the Gemara (Nedarim 32a) finds fault with Avraham that he had the opportunity to bring the people of Sodom under the 'Wings of the Divine Presence' but did not. Had could have had, quite literally, a 'captive audience' for his Kiruv seminars. But he let them go, and even gave back their property, though he allowed his soldiers to justifiably partake from the spoils and also gives 10% to God (indeed, Abraham is seen here withstanding the last temptation of Christ well before Jesus does).
There are really two ways to look at Avraham at this point. Malkitzedek sees Avraham as a saint, someone blessed by God. Avraham fights and wins, but refuses the trappings of victory because he fights for God. The King of Sodom sees Avraham as a monumental frayer. After seeing Avraham part with 10% of the spoils, he tries to beg Avraham for help, and ends up getting even more than he was bargaining for.
We would expect that encountering such incredible magnanimity, that Sodom, starting with the king, might have taken it to heart. It's one thing to be cruel. Lots of people are cruel. It's another thing to be the beneficiary of charity, to truly encounter compassion and mercy at its best, and then to go right back to evil. If the point of Avraham's career was to spread the word of God through acts of kindness and love, then Sodom was his greatest failure, though not for lack of trying. They thus forfeited their claim on the land of Israel, as recorded in the words of the Nevi'im, and were destroyed.