The answer is a little more complicated than you may think. It may have a lot to do with rocks, phosphorous and ancient algae, according to a new study.
For the first two billion years of Earth's history or so, the sky was probably orange. We're not sure whether that's really true - no one's been able to hop in a time machine and go back and check - but based on what we know about the chemistry of that time period, there's a good chance the atmosphere's primary component was methane (CH4), which would've cast a strange pall over our young planet.
These days, the atmosphere is mostly nitrogen and oxygen. Sunlight is made up of all the colors of the rainbow (as well as many wavelengths we can't see); as it jostles through air molecules, blue light is most efficiently reflected, so our eyes end up experiencing a beautiful azure shade.
How did it change from orange to blue? About 2.5 billion years ago, the newest fad in organisms was photosynthesis - the ability to to turn sunlight, carbon dioxide (CO2) and water into sugar. Armed with the latest evolutionary accoutrement, ancient algae had it made - an everlasting food source and all the world's oceans to expand into.