The sky is blue because of the way different light frequencies scatter and because we have evolved to see a pure color.
The sky would be white if all light frequencies scattered evenly. The light from the sun is white. A prism is able to break white light into the colors of the rainbow because the different colors refract at different angles.
The “blue” part of the light spectrum has shorter frequencies and is more easily scattered. So molecules of nitrogen and oxygen in the Earth’s atmosphere spread the blue part of sunlight out more.
Away from direct sunlight, there is less green and even less red. Red is the longest frequency part of the color spectrum.
Why Sunsets are Orange
We see orange and red colors at dawn and dusk because of the same effect. The sharp angle of sunlight at these times means that blue light bends beyond our field of vision. This means we just see the longer end of the light frequency: orange and red.
How Our Vision Works
The blue appearance of the sky is also due to the way our vision works. Violet and indigo are present in the blue sky. However, the amounts are smaller and our eyes are less sensitive to these colors. Our eyes contain blue, green and red cones / receptors and the configuration has evolved to see the sky as a pure pale blue.