When you insert a plug into an outlet in your house, you connect directly to the plant that generates the electricity you use, via a line transformer and a panel. It only takes two pins to do this. The third pin on some plugs grounds the circuit and prevents shocks and fires.
The alternating current provided by the power company passes between two live, or "hot", wires in the panel, with a total of 240 volts between them. When an electrician wires a receptacle, he does it with one of these hot wires and a neutral wire that returns to the transformer to complete the circuit. This creates a 120-volt circuit. When you insert a two-pin plug, one pin connects to the hot wire and one connects to the neutral to extend the circuit through the wire to which the plug is attached.
During the installation of an electrical system, the electrician grounds the panel with a metal rod or some other means that provides a pathway for electricity to disperse into the earth. He connects each electrical device on the circuit, including all receptacles, to this ground path with a separate wire. Proper grounding prevents the build-up of charge on poorly insulated devices that can cause shocks and start fires. The third pin on a plug connects the plug to this ground path.