There are three types of eruvs. These are:

1) Eruv Tavshilin—allows one to cook on Yom Tov for the sake of Shabbat.
2) Eruvei Techumin—allows a person to walk more than 2000 cubits outside of a city on Shabbat or Yom Tov (Only used in cases of pressing need)
3) Eruv Chatzeirot—the most commonly referred to, and the one most people mean when they say "eruv"; explained in this article.

One of the 39 melachot forbidden on Shabbat is carrying from a private to a public domain or within a public domain. Private domains are residential areas, and originally referred to an individuals home or apartments that were surrounded by a "wall" and can be deemed to be "closed off" from the surrounding public domains. Public domains are non-residential areas like thoroughfares, highways, and open plazas.

What's if one lives in a small neighborhood that is primarily Jewish but not surrounded by a wall? Clearly, the area outside each private home counts as the "public domain" and carrying objects from one home to the next is forbidden. However, there is a way to make these larger areas and even whole cities one private domain: the circumvention of the whole domain by a wall or gate, which would permit carrying throughout the entire city. This wall or gate, the Eruv, is an enclosure that legally transforms a non-private public thoroughfare into a private domain.

The sages, however, were concerned that people would entirely forget about the prohibition of carrying on Shabbat, so they established the concept of eruvei chatzairot.

Everyone in the city (or area of the eruv) contributes food (or, as is usually done, one person in the city can supply the food for everyone) and this food is kept in one of the houses. [Today, eruvs are normally done with matzah, because it lasts a long time and doesn't have to be replenished very often.] This symbolizes that all the people who dwell within the eruv are now 'sharing' food, and are therefore one big happy family living in one "private" domain. In fact, the word eruv actually means, "mixing"-- its purpose is to blend and mix the entire community together.

This must, of course, go along with the physical enclosure of the eruv of the city (or area). According to Jewish law, the enclosure does not have to be actual walls, rather they can be continuous posts connected with string or wire according to very exact halachic specifications for height, distance between the posts, and method of attachment. Erecting these poles and running the cable is significantly more difficult than making the actual (food) eruv. in fact, the laws of eruv are from the most complicated laws in the Talmud and thus putting up an eruv requires expert assistance and input from a rabbi.