The people of Sodom were very evil and sinful to G‑d.(Genesis 13:13.)

They were souls of Tohu, desiring complete independence from one another. (Rabbi Shalom Dovber of Lubavitch)

From a letter of the Rebbe to an Israeli professor:

You write that the geulah cannot be complete until “there will no longer be needy people upon the earth” (Deuteronomy 15:11) and all people will work collectively with shared responsibility so that there will be no distinctions of poor and rich.

I do not agree. Human nature is such that we only feel fully satisfied when we are able to help someone else. And that is only possible when one person is rich and another is poor.

Yet there is no contradiction here, and you are correct when you say that it really is unjust for society to be divided into those who have and those who have not.

You see, as explained in the teachings of Chassidut, every created being, as long as it behaves the way it was created to behave, not only receives, but also contributes to its environment.

The same here: If someone is a needy recipient in one aspect, that same person is a wealthy provider in some other aspect.

This truth is so universal, it extends to the ultimate extreme: Even when it comes to the Creator and Director of the Universe Himself, the Torah tells us, figuratively speaking, that He too is also sometimes a recipient, and not just a provider.

This is explained in works of Chassidut on the verse, “You yearn for the work of Your own hands.” In a certain way, we can say that the Creator yearns for His creations to make His presence tangible in His world.

Then there is the Chassidic commentary on the language of our sages, “Our service is needed above.” He has so chosen, after all, to rely on us small creatures to do His mitzvahs and thereby complete His creation.

—Igrot Kodesh, vol. 13, p. 234.

More on this: The Isolationists of Sodom and Gomorrah