The reason the sky appears blue is because of an effect called scattering. Sunlight has to pass through the Earth’s atmosphere, which is filled with gases and particles that act like the bumpers on a pinball machine, bouncing sunlight all over the place. But if you’ve ever held a prism in your hands, you know that sunlight actually is made up of a bunch of different colors, all of which have different wavelengths. Blue light has a relatively short wavelength, so it gets through the filter more easily than colors with longer wavelengths, and as a result are scattered more widely as they pass through the atmosphere. That’s why the sky looks blue during the parts of the day when the Sun appears to be high in the sky (though it’s actually the spot on the planet where you are standing that is moving, relative to the Sun).
At sunrise and sunset, though, the sun’s rays have to travel a longer distance to reach your position. That cancels out blue light’s wavelength advantage and allows us to see the other colors better, which is why sunsets often appear red, orange or yellow [sources: NASA, ScienceDaily].