Magenta isn't a thing...
Isaac Newton wasn't the first person who noticed that when light passed through a prism, it transformed into a rainbow of colors, but he was the first to figure out (roughly) why. Before him, people had supposed that the prism somehow corrupted the color of the light. Newton took that rainbow, passed it through another prism, and "re-assembled" it into its original state (white light), and deduced correctly that white light is actually made up of many different colors. He even charted it out, making a linear bar of all the colors, from red on the left to violet on the right.
But then he noticed that a popular visible color -- magenta -- was not in the spectrum. Magenta was really a combination of red and violet. So Newton took the his linear color spectrum and made it a circle, joining the red and violet ends, thus giving birth to the color wheel that is, in some form, part of every beginning art class today. This was work he did between 1666 and 1672; he was in his 20's, and well on his way to laying the foundations of modern physics. You should be awed.
...and neither is Roy G Biv.
Newton's spectrum of visible colors is a continuous gradient from red to violet, with no clear delineation between the colors. How then did we end up with red, orange, yellow, green, blue, indigo, and violet, the seven colors that we all memorized as Roy G Biv? Well, seven was an important number back then: 7 days in a week, 7 known planets, 7 musical notes in the diatonic scale. The idea of that sort of unity was important to the thinkers of the day, even if it made for a somewhat arbitrary division, and led to a color wheel with uneven segments.
In modern times, when teaching our children, we tend to indulge the great man and accept his assertion that indigo is a separate color. But in practice, the most basic color wheels quietly lose indigo, shove blue and violet together, and present a pleasing circle, symmetrically divided into six segments. We should not let this diminish our estimation of the man's genius; the basic concept is still intact, 350 years later. The middle of his circle is the white that results from combining all the colors, and the colors get more intense (the saturation increases) as we move towards the perimeter.
The wheel keeps on turning
The color wheel has continued to evolve to reflect new developments in color theory, assuming new and more complex configurations. But at its heart, it is a tool to help artists combine color in the most effective way. Three common concepts are analogous, complementary, and triadic color combinations, and these are all based on the colors' relative positions on the wheel. Analogous colors are next to each other, and they go together in a very natural way. Complementary colors are in opposite positions on the wheel, and tend to accentuate each other. A triadic color scheme uses three colors that are evenly spaced along the wheel, and these provide a high-contrast, vibrant palette.
And now for the math...
Software can represent colors with numbers, so the next logical question is: can we use math to calculate color combinations? Of course! Using the familiar RGB notation, a color can be identified by three numbers, each between 0 and 255. To calculate the RGB coordinates of a color on the opposite side of the wheel (its complement), we do the following:
Here's our color: R(220), G(50), B(120)
We take the highest and lowest RGB numbers and add them together, so 220 + 50 = 270.
Then we subtract each RGB number from this sum:
270 - 220 = 50 (this is the new "R" number)
270 - 50 = 220 (this is the new "G" number)
270 - 120 = 150 (this is the new "B" number)
So our new complementary color is: R(50), G(220), B(150)
Calculating a triadic combination is even easier. We just "rotate" the RGB numbers. Starting with our original color, our triadic scheme would be:
R(220), G(50), B(120)
R(50), G(120), B(220)
R(120), G(220), B(50)
Cool, huh? (You're a geek if you say "yes")