Before we start, we should probably define some terms for anyone who hasn't been blessed with a circuit theory course. Voltage is a measure of the difference in electric potential between two points (the fact that there's no such thing as an absolute voltage is very confusing if you're not used to thinking like a physicist). Since it's a completely relative measurement and math is always easier when there are some zeros involved, it usually makes sense to simplify things by calling one of the points in a circuit "zero volts," or more commonly, the "ground." Then you can define all the other voltages in the circuit relative to that ground. Again, it's a totally arbitrary thing, since all that matters is the difference between the chosen ground and the other parts of the circuit.
A three-prong electrical socket has three wires in it: the "line" wire, the "neutral" wire (the two flat prongs), and the "ground" wire (the little round one), the last being the source of confusion here. In normal circuit-theory talk, the neutral wire would be called the ground; it's the zero point that the voltage on the line wire gets defined in reference to. To avoid/enhance confusion though, we don't call it the ground, because that would both make sense and mean we had to find a new name for the ground plug. So the ground-like word "neutral" gets used instead. I have a feeling misuse of naming conventions is one of the main things that makes this so unnecessarily confusing.
I started with the few things I definitely knew about the ground prong:
- Its existence gives you a much more stable line voltage, which is important for things like audio, sensitive lab equipment, and anything where precise analog signals are used.
- Two-prong outlets are generally considered to be a shock and fire hazard; I'm not even sure if it's legal to build a house using two-prong outlets in the US anymore
It's easy to forget how idealized circuit theory is. In a circuit diagram, wires have zero resistance and can conduct an infinite amount of current without seeing any kind of voltage drop along their length. So in a circuit diagram, the part you've defined as "ground" stays at zero volts along its entire length no matter what happens. Basically we're operating under the assumption that any resistance in the lines is negligible compared to resistance in the circuit elements themselves, which in most normal situations is a perfectly reasonable thing to assume.
In real life, of course, things get messy. A two-prong electrical outlet isn't an isolated, magical voltage source; both prongs are connected to a series of power lines, transformers, and other things leading all the way back to the power plant where said voltage was generated. All of this stuff has a low but finite resistance to it. Run current through anything with resistance and you'll get a voltage differential between one side of the element and the other (V=IR, remember?)-- the higher the current, the more severe the voltage drop. All that stuff between the electrical system's "ground" point (there's usually one at the transformer on your street, Americans) and your outlet means that when you plug something into it (running current through it, effectively), cumulative line resistance means that the voltage you see at the outlet will be less than the voltage at the originating point.
This is problematic for two reasons. The most obvious one is safety. While under normal operation that line resistance is negligible, say the circuit gets hit by lightning and sees a brief 100,000-volt spike. Way more voltage means way more current traveling down the lines which, as you'll recall, are slightly resistive. Running current through a resistor generates heat. Heat can make things catch on fire. Do the math here.
The other, more subtle issue is voltage stability. Not only are the lines resistive, but they can't even be relied on to be predictably resistive; things like temperature variations, stray electromagnetic interference, and load variations in the power grid will all affect line resistance slightly. Again, this is ordinarily negligible, but if you're doing something with precise analog signals you really want a line voltage with as little fluctuation as possible.
The ground prong solves both of these problems by providing a low-resistance path directly to a ground right from the circuit, instead of locating the ground point all the way at the other end of the neutral line. "Ground" (more accurately called "earth" in Europe) is usually exactly what it sounds like-- since the earth is a) quite large and able to sink a basically infinite amount of current, and b) everywhere, the best ground points are actually just big metal rods hammered into the ground. For reasons that are probably obvious though, this can be impractical, so in a pinch anything metal that's big enough to run a lot of current into without much of a voltage drop will work; grounding to things like metal pipe systems and iron girders is pretty common when an earth ground isn't available, although that can create unique problems of its own (in one of my old labs, we actually drove a copper rod four stories down through the building and into the ground from our lab so our ultra-sensitive SQUIDs would have the most stable possible reference).
So now you've got a very direct path to ground on your circuit. That means that if you tie that ground to the neutral wire, the neutral wire will be at zero volts both at your end and at its originating point. For best results, the path to ground should be short and the conductor used to get there should be as large as possible to minimize line resistance. In most cases, the ground prong is just sitting there holding your end of the neutral conductor at zero volts, so there's no actual current flowing through it; everything still goes back through the neutral wire, but now we don't have to worry (as much) about a voltage drop when it does so. In extreme cases like our lightning strike, the fact that our ground wire is a much more direct path to ground than the neutral wire mean that all that excess voltage will "see" a much lower resistance along the ground conductor. Electricity being as lazy as everything else in the universe, the excess current will travel to ground via the ground line instead of the neutral line, and since you designed your ground wiring with as low a line resistance as possible, it means something is way less likely to catch on fire.
There are other safety things to consider too. If you build something with a metal chassis (like a refrigerator or computer), it's a good idea to ground the chassis so if a mis-wired "line" wire inside the device somehow came into contact with the chassis, it would just create a short circuit and blow your fuse/breaker instead of energizing the chassis to line-level and zapping the next person who touched it. The neutral line will work perfectly well for this, but it's also really easy to accidentally cross-wire a two-prong outlet when you install it, and anything using the neutral line as a chassis ground that's plugged into a cross-wired will instead have its chassis permanently energized to line-level, turning it into a shock machine. The three-prong design (with the third prong looking conspicuously different than the first two, both inside and outside the outlet) is much harder to screw up this way, so to be on the safe side it's generally a good idea to ground a metal chassis using the ground, rather than the neutral, wire.
As any of the electrical engineers shaking their fists at the screen right now will be happy to tell you, there are entire books' worth of grounding techniques and arcana that I've skipped over here, but strictly in terms of answering the question of "what's the third prong for?," those are most of the essentials. While the whole thing was a little more complicated than expected, this particular journey of discovery is a good demonstration of this blog's operating principle: that it's possible to get a Ph.D and still not know a large number of very basic things, including things in the field you got the Ph.D in. It seems like the world's greatest scam until you remember that you still have to spend 4-7 years in grad school, something I wouldn't wish on my worst enemies.