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.
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).
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.
EDIT: Both images had the line/neutral plugs reversed. This has since been corrected.