The short answer:
The scattering of light is dependent on the wavelength.

Now what does that mean?
Imagine the following:

                              (scattering)
----------------------------------0-------------------------------> (ray of light from the sun)
       (white - all colors)       |                (red)
                                  |
                                  | (blue)
                                  |

                                (you)
                   ++++++++++++++++++++++++++++++               
         ++++++++++                              +++++++++++
    +++++                                                   ++++++
++++                  (surface of the earth)                    +++++

The light from is sun is actually white light, meaning that it contains all colors (look at a rainbow). If there was no scattering, the sky would be black like during the night, because the light from the sun would just pass through the atmosphere and never fall into your eyes.

But in fact there are even two kinds of scattering at work here! One is called Rayleigh scattering (with very small particles and molecules), the other Mie scattering (with larger particles, eg in fog or haze). The former is much more important here and strongly dependent on the wavelength (proportional to 1/λ4, to be precise), meaning that blue light gets scattered much more. Therefore the red light never reaches us and the sky looks blue! This scattered light will also be polarized (the deeper reason for this is that it's dipole radiation) - that's why the sky looks even more interesting through a polarization filter.

Other examples for the same effect:
  • A sunset looks red because this time we only see the red remnant of the original ray. During daytime it's not so extreme (the angle is steeper and thus the light does not have to penetrate so much air) and the sun "only" looks yellow.
  • Distant mountains look blueish because there's much air in between us and them that scatters blue light from the sun in our direction.