The sky is blue for the same reason that cigarette smoke is blue: the preferential scattering of blue light by tiny particles.
Pure air is colorless, of course, meaning that all visible wavelengths (colors) of light pass through it without being absorbed. But it contains molecules and, often, suspended dust motes that are smaller than the wavelengths of visible light and that therefore scatter it.
As is the case with the cigarette smoke particles, the blue light is scattered more than the other colors, which tend to go straight through the air without much change of direction.
When you look at the sky, you’re seeing all the colors in sunlight that are coming down toward you, mainly from some direction off to one side, wherever the sun happens to be. But in addition to that, you’re getting some extra blue light that is being “scattered off the air” from many other directions.
Thus, you’re receiving an excess of blue light over what the sun is putting straight out, and the sky looks bluer than the sun’s own daylight.