The sky is not blue everywhere. Pictures taken in outer space show the Space Shuttle against a black background.
Lunar scenes portray astronauts against a black sky.
The Earth, unlike the moon or space, has a protective blanket of gases, water and dust called an atmosphere. The blue color of the sky is a result of sunlight passing through and interacting with the atmosphere. If you look at sunlight passing through a prism, you will find that white sunlight is actually composed of a rainbow of colors. Scattering of light can be simply thought of as a light wave bouncing off of the air, water and dust particles which make up the atmosphere. An example of the scattering of sunlight can be seen in a smoke filled room.