Water appears blue due to the way it absorbs and reflects light. Water molecules tend to absorb long-wavelength parts of the light spectrum and reflect shorter wavelengths. When white light strikes water, red, orange and yellow light gets absorbed, while blue light is reflected. The deeper the water, the more water molecules there are to absorb other wavelengths, and the more vividly the water appears to be colored.
The reason blue light penetrates water so well is that light on that end of the spectrum has a higher energy than longer wavelengths of light. This means it loses less energy when striking water molecules, allowing it to continue to reflect back to the viewer's eye. If a diver looks up as he descends from the surface, gradually everything around him loses color as less and less red and orange light survives collision with water molecules to reach the depths. However, a flashlight restores normal color to nearby objects, since the light source is much closer to the subject.
A similar effect causes the sky to appear blue. Molecules of air scatter light waves and their composition causes blue light to scatter more readily than other parts of the spectrum. This means that when an observer looks into the sky, blue light strikes the eye from many different directions at once, giving an overwhelming blue color to the atmosphere.