Why is the sky blue? You may think that it is because of the ocean (a lot of people do), but it is not. To answer this question, we should begin with the Sun itself. Ultimately, the Sun is just a big hydrogen-fusing ball of plasma with a surface temperature of about 5,507°C (9,944°F). At this temperature, the Sun radiates strongest in the green part of the spectrum. That really just means that it emits the green light the most (if you’re wondering why the Sun appears yellow as opposed to green, see this article.).
It is at this point that we can come to understand a little more about the light that the Sun is producing: It peaks in the green part of the spectrum, but a very broad range of electromagnetic radiation (light) is being given off. It produces everything from X-rays and UV radiation (which causes sunburn) to radio waves. When the electromagnetic radiation eventually hits the Earth, just about the only part that doesn’t reach the surface is the X-rays, as they’re blocked by the atmosphere.
When light enters the atmosphere, it has to pass through all the molecules it encounters. X-rays, as we just noted, are blocked entirely. Other forms of radiation make it through, but they are scattered by the molecules that they encounter—bouncing from one to another until they make it through. The more energetic part of the spectrum (blue) is scattered more than the less energetic (red), meaning that the less energetic light (red) is able to pass through relatively unscathed.
When the blue light is scattered, it is scattered in all directions, causing the entire sky to be blue.
You might now be asking why the sky isn’t violet (because violet it more energetic than blue, so shouldn’t it be scattered more and make the sky appear more purply?). We can see violet, so it is not at all unreasonable to ask this question. In the end, our eyes distinguish colour by “seeing” in three colours: Red, green, and blue. This means that, to be able to see violet, we have to mix two colours together: Red and blue. Since red light isn’t scattered much, there isn’t enough red for our eyes to process. This is why we don’t see the violet sky.
Sources and further reading: