The following discussion is accompanied by this tutorial and its correction.
It seems natural to everybody that the sky is blue (when it is not hidden behind clouds), but finding why it is so has proven to be much more difficult.
In the (colour) pictures taken by the Apollo astronauts on the moon, the sky is not blue but completely black. The blue of the sky is therefore clearly related to the presence of an atmosphere on our planet: there is air on the surface of earth, nothing on the moon.
Colour photograph taken by one of astronaut from Apollo 17 (NASA).
Our atmosphere is mainly constituted of nitrogen (N₂) and oxygen (0₂) molecules. The electrons of these molecules vibrate under the influence of the light coming from the sun, and emit an electromagnetic wave at the same frequency. That's why our sky is not pitch black, because the electrons around the molecules of air scatter sunlight.
This phenomenon is however not always efficient. In particular, it does not work very well for the lower frequencies of the visible spectrum (what we perceive as red), and is very efficient for violet light, at the other extremity of the spectrum. The following image compares the spectrum form the sun, and the one scattered by the sky. Such a spectrum in which higher frequencies dominate is perceived as blue by our eyes.
Spectrum of sun light (top) and from the light scattered by the sky.
These explanations can be formulated in a more physical sense, to further understand the "blue of the sky." I made a tutorial (in French) to fulfill this goal. It requires a decent knowledge in physics (Bachelor in Physics and above), the first part is quite difficult, but it's worth the effort! Here is the correction, to check your calculations are good.
Please do not hesitate to contact me if you find any mistake, or unclear explanation, or if you have comments.