The sunlight is made up of all the colors of the rainbow. When it reaches Earth's atmosphere the blue light which travels in shorter waves is scattered in all directions by the gasses and particles in the air. The most of the longer wavelengths (red, orange) pass straight through. That's why the sky is blue.