Why both yellow and purple light could be made by a mix of red, green and blue?

The reason that colors combine as they do has everything to do with the response curves of the light-sensitive proteins in your eye. A response curve is just a function that tells you how strongly a particular protein reacts to a fixed amount of light a given frequency (or energy). There are three kinds of these photosensitive proteins (photopsins) in our eyes, one for each of the three different kinds of cones on the retina, and each has a distinct response curve, which you can see e.g. in this image on Wikipedia:

color response curves

When light of a particular frequency comes into the eye, it triggers a certain strength of reaction from each of the three kinds of proteins. For example, light with a wavelength of 580 nm causes the "short" protein (the one that responds most strongly to short-wavelength light) to produce a signal of strength 0.000109, the "medium" protein to produce a signal of strength 0.653274, and the "long" protein to produce a signal of strength 0.969429. It's this set of signal strengths, (0.969429, 0.653274, 0.000109), that triggers the perception of that particular shade of yellow in our brain. (Numeric data come from this site)

But as you might guess, it's possible to "fake" this signal by sending a particular combination of different frequencies of light. For example, you might guess that if you send a combination of 97 parts long-wavelength light and 65 parts medium-wavelength light into the eye, it would produce almost exactly the same set of signal strengths: (0.97, 0.65, 0). In practice you have to be a little more careful than that, because the response curves overlap a bit, but the basic idea that a combination of multiple wavelengths of light can produce the same signal as a single, other wavelength of light, definitely works. This is why red and green combine to produce yellow, for example. It's not because yellow is between red and green in the spectrum, it's because the signal strengths generated when our eye receives yellow light are very nearly the same as the signal strengths generated when it receives a certain combination of red light and green light. Similarly, the signal strengths generated when our eye receives purple (actually violet) light are very nearly the same as the signal strengths generated by a certain combination of red light and blue light.


The above is adapted from a comment I posted on Reddit, and for more information, you might want to look at an earlier comment describing how wavelengths of light (or combinations of wavelengths) get converted to colors.