A portion of the light coming from the sun scatters off molecules and other small particles in the atmosphere. It is this scattered light that gives the sky its brightness and its color.
As previously explained, Rayleigh scattering is inversely proportional to the fourth power of wavelength, so that shorter wavelength violet and blue light will scatter more than the longer wavelengths (yellow and especially red light). The resulting color, which appears like a pale blue, actually is a "weighted average" of all the scattered colors, mainly blue and green (violet, though strongly scattered, is a minor component of the solar spectrum and is less efficiently detected by the human eye); its hue is intermediate between blue and green[3]. Conversely, glancing toward the sun, the colors that were not scattered away—the longer wavelengths such as red and yellow light—are visible, giving the sun itself a slightly yellowish hue. Viewed from outer space, instead, the sky is black and the sun is white.
The reddening of sunlight is intensified when the sun is near the horizon because the volume of air through which sunlight must pass is significantly greater than when the sun is high in the sky. The Rayleigh scattering effect is therefore increased, removing virtually all blue light from the direct path to the observer. The remaining unscattered light is mostly of a longer wavelength and therefore appears to be orange.
Rayleigh scattering - Wikipedia, the free encyclopedia