A blanket of air called atmosphere, surrounds our earth. It is mainly composed of nitrogen, oxygen, carbon dioxide, dust particles, water vapors and other gases. The light coming to us from the sun has to travel through this atmosphere.
We all know that the sun is the main source of light for earth. When the sunlight passes through the atmosphere, it is scattered by the dust particles, water vapor and air molecules in all the directions. This is the reason why light is all around after the sunrise.
Do you know that the sunlight is composed of seven colors- violet, indigo, blue, green, yellow, orange and red? When the sunrays pass through the atmospheric molecules, the violet, indigo and blue colors get scattered most and the red color least of them. Therefore, when we look at the sky, the light that enters our eyes mainly consists of violet, indigo and blue colors. The mixture of these three colors is almost blue. That is why the sky appears blue.
If the earth had no atmosphere, the sky would have just appeared dark. This fact is clear when we look at the sky from the surface of the moon. It appears dark since there is no atmosphere in the moon. Similarly, the sky appears dark when we look form a spacecraft, because there are no light scattering particles in the higher space.