Visible light is the part of the electromagnetic spectrum that our eyes can see. Light from the sun or a light bulb may look white, but it is actually a combination of many colors. We can see the different colors of the spectrum by splitting the light with a prism. The colors have different wavelengths, frequencies, and energies.
When the sun's rays enter the atmosphere they collide with particles and gases in the atmosphere. In 1871, Lord Rayleigh derived a formula describing a subset of these interactions, in which atmospheric particles are much smaller than the wavelengths of the radiation striking them. The Rayleigh scattering model showed that, in such systems, the intensity of scattered light varies inversely with the fourth power of its wavelength. In other words, shorter wavelengths, like blue and violet, scatter a lot more than long ones when particles are relatively small.
Under these conditions, scattered light also tends to disperse equally in all directions, which is why the sky appears so saturated with blue color. Also the sky does not appear violet because though our eyes are sensitive to all the colors the ranges of the blue and violet overlap. Hence our receptive cones perceive blue color.
The sky's color can change based on dust, pollution and water vapor, which affect the absorption and scattering of sunlight differently. The reddish tinge of sunsets is due mostly to the fact that the sunlight travels through more atmosphere to reach our eyes.
By the time the light arrives, it's been stripped of shorter wavelengths, which have scattered away, leaving only the longer-wavelength, direct illumiof sunlight's redder tones.