GPS was developed by the U.S. Department of Defense, and at any given time consists of a minimum of 24 satellites in orbit around the earth. Once intended for military purposes, in 1996 GPS access became available to the general public, and in 2000 the Selective Ability of GPS was discontinued (giving the global public access to full, non-degraded signals. Today's extremely-accurate GPS tracking was the result).
A GPS receiver works by locating three or more GPS satellites, and sending a signal to each. The satellites all receive the signal and each one sends a response, containing time and information on the satellite's position. The receiver gets the response, then uses the time delay information to calculate the distance to each satellite. Knowing how far away it is from each of the three satellites, the receiver can figure out its exact location.
GPS systems are incredibly accurate: with three satellites in view, a WAAS-enabled GPS receiver can calculate your position to within 10 feet of where you are. With four satellites in view, you can even determine your position in 3D (meaning if you're flying a plane, you can figure out its altitude, too).
All-in-all, it's one of those brilliantly-simple things that we're already starting to wonder how we lived without.