Light, and the color that is connected with it, is the basis of photography; however, many things that our brains do automatically, our cameras have to be programmed to deal with. One of those things is color “balance”. Producing each and every color individually would be prohibitively complicated, so a simpler solution was needed for displays and, eventually, photodetectors. Thankfully, the solution had already been developed by Thomas Young, Hermann Helmholtz, and James Clerk Maxwell in the form of color mixing, a technique fundamental to color reproduction in painting and an analogue of how our own eyes detect color (though displays and detectors use additive color mixing rather than the subtractive used in painting and printing). Values are assigned to each color, with 0 representing no light whatsoever and the maximum value representing white.
The color of an object doesn’t just depend on the object itself. The color of the light source has a strong effect on the appearance of a scene, with higher temperature light sources leaning towards the blue end of the spectrum and lower temperature sources being more reddish in color. When you add this factor into the color mixing that produces the specific color s in your image, dramatic differences can result.
Though colors can be broken down into components and later reconstructed, your eyes and the imaging sensor in your digital camera do not see things the same way - they don’t have the same level of sensitivity to red, green, or blue wavelengths of light. As a result, the levels of the colors that your camera records reproduce an image whose color may differ from what you saw when you took the photograph. To make matters even more complicated, these levels vary from device to device, due to variations in design and materials, and may vary again when you go from recording device to display device. Neutral colors are especially important to accurate reproduction of a scene, since coloration of a neutral color adds a noticeable tint to the image.
In order to compensate for this, photographers developed a technique that uses a neutral color such as grey or white to evaluate the color temperature of the light source and adjust the image accordingly. In the case of your digital camera, it uses information about the light source in the photograph through either manual input of a color temperature for the source, use of a neutral reference, or the automatic estimation of a white balance.