Rayleigh scattering.

The sunlight scatters off the molecules of the atmosphere. On a clear day you have the shorter wavelength blue ( I forget which particular constituent of the atmosphere does this..perhaps oxygen ) predominant and thus the sky is blue.

This scattering effect also gives you sunsets of different wavelengths being scattered off of and other atmospheric conditions also result in Rayleigh scattering of a different sort. In fact there are two mathematical expressions covering the variation in Rayleigh scattering. ( too late for me to look them up now, perhaps tomorrow. )