Moisture occurs naturally in the air. When the air is hot, moisture remains in a gaseous state. When the air cools, it condenses as water. In the winter time, your house is hot on the inside, and cold on the outside. In the summer, it's reversed when you have the air conditioner on. When hot air meets cold air inside the wall, moisture condenses out, leaving water inside the wall. This causes a variety of problems, including wood rot and mold growth.
A physical barrier must be placed between the hot and cold air to prevent condensation. A vapor barrier does exactly that. It separates the air into two parts, namely the hot side and the cold side. A vapor barrier prevents cold and hot air intermixing, preventing water condensation.
A variety of materials can be used, but the most common is polyethylene film sheeting, according to Kansas State's Engineering Extension Service. Polyethylene film sheeting is inexpensive and available at any building supply store. Some rolled fiberglass wall insulation has a built-in vapor barrier glued on its face, but wise builders go the extra step and install poly sheeting, too.
The placement of a vapor barrier is easy. Install the insulation first. After, simply attach the polyethylene sheeting to the the studs just before installing the drywall. A common carpenter's stapler, shooting 1/4-inch long staples, usually secures the barrier in place. For attics and ceilings the same placement, just behind the drywall, applies. If the ceiling drywall is installed already, Kansas State recommends spreading the vapor barrier on top of the drywall, and add in insulation on top of the vapor barrier.