Most of the following info can be found in the GPS Standard Positioning Service Performance Standard
First, I fear I'll have to correct your number, because you need 24 satellites for 100% coverage.
100% coverage means that there are at least 4 GPS satellites in sight at every point on Earth at all times.
Your position is calculated in the following way: Every satellite sends out a signal containing the time and the position of the satellite relative to the center of the Earth. You need three satellites for the three unknowns in the coordinate, and one more satellite to account for the unknown amount of time the signal needs to travel to your personal position.
The current configuration of the satellites is as follows: The satellites cover six orbital planes with 4 satellites each. The orbital planes are inclined by 55° against the equator. While the orbital planes are distributed evenly, the satellites within them are not! At this point, I'd like to quote Wikipedia on GPS:
The orbital period is one-half a sidereal day, i.e., 11 hours and 58 minutes so that the satellites pass over the same locations or almost the same locations every day. The orbits are arranged so that at least six satellites are always within line of sight from everywhere on the Earth's surface. The result of this objective is that the four satellites are not evenly spaced (90°) apart within each orbit. In general terms, the angular difference between satellites in each orbit is 30°, 105°, 120°, and 105° apart, which sum to 360°. Orbiting at an altitude of approximately 20,200 km (12,600 mi); orbital radius of approximately 26,600 km (16,500 mi), each SV makes two complete orbits each sidereal day, repeating the same ground track each day. This was very helpful during development because even with only four satellites, correct alignment means all four are visible from one spot for a few hours each day. For military operations, the ground track repeat can be used to ensure good coverage in combat zones.
Here is an image to visualize the configuration (also taken from Wiki):
So the answer to your question is: The number 24 is valid for the current configuration and takes into account the position of each satellite in the respective orbital plane. I do not think it is the mathematical optimum. Note that the system is also setup in a redundant way. There are at least 6 more active satellites to guarantee coverage when satellites need to be repaired.