The eruv, the two meals’ worth of food that all residents within the enclosed area own jointly, unites all the residents and renders the enclosed area a private domain, where carrying is permitted. However, all this is on condition that all the area residents, without exception, are partners in the eruv. If any one of them is not interested in participating, then the area can no longer be considered a single domain, and the eruv is invalid.
In light of this, it is problematic to implement an eruv in cities and towns whose residents include Jews who do not observe Shabbat. Since they are not interested in an eruv, they and their homes are not included in the partnership of the eruv, which means the eruv cannot be valid. The same problem exists if a non-Jew lives in the area; since his home is not included in the eruv, the eruv is invalidated (SA 385:3; 382:1).
The solution is for the Shabbat desecrator or non-Jew to rent out his home for Shabbat to one of the Shabbat observers. This way his home will be included in the eruv as well. The problem with this solution is that it is almost impossible to implement in large towns, let alone cities. Therefore, it became customary to use a different solution – renting all the homes in the area from a city official who has the authority to enter every house in the city (SA 391:1).
Some argue that this solution is not viable today. In a democratic country, the mayor of a city does not have the right to enter the home of a private individual without a warrant. Still, the custom is to be lenient. After all, during wartime, the town major and the head of home front command may requisition homes of their choosing. They may even do so during training exercises. Therefore, these authorities have a share of ownership in all the homes, and one may rent their share from them before Shabbat for the purposes of the eruv.
It should be noted that we always tend to be lenient regarding the issue of constructing an eruv in a place where Shabbat desecrators live. This is because the prohibition on including non-Jews or Shabbat-desecrating Jews in an eruv is really a punitive stringency; technically, they may join with Shabbat-observing Jews to form an eruv partnership. The Sages wanted to discourage observant Jews from living in neighborhoods with Shabbat desecrators and non-Jews, so they penalized those who did so by forbidding such an eruv. However, if there is no alternative, we make use of any reasonable justification to be lenient and participate with all local residents in making an eruv. See Ĥazon Ish 18:9; AHS 391:4; Menuĥat Ahava vol. 3, p. 363.