The light coming from the sun is white. This white light is made up of all colours of the rainbow. Like energy passing through the ocean, light energy travels in waves, too. Some light travels in short, "choppy" waves. Other light travels in long, lazy waves. Violet and blue light has shorter wavelengths, while red light has a longer wavelength, and the other colors have wavelengths in between.
All light travels in a straight line unless something gets in the way to—
§ reflect it (like a mirror)
§ bend it (like a prism)
§ or scatter it (like molecules of the gases, water droplets, dust etc in the atmosphere)
Sunlight reaches Earth's atmosphere and is scattered in all directions by all the gases and particles in the air. Blue light is scattered in all directions by the tiny molecules of air in Earth's atmosphere. Blue is scattered more than other colors because it travels as shorter, smaller waves. These particles scatter violet and blue light much more than red, and so they send rays of violet and blue toward the ground — and our eyes. More violet light actually gets scattered by atmospheric particles than blue light, but our eyes are more sensitive to blue, so the sky appears blue.
Closer to the horizon, the sky fades to a lighter blue or white. The sunlight reaching us from low in the sky has passed through even more air than the sunlight reaching us from overhead. As the sunlight has passed through all this air, the air molecules have scattered and rescattered the blue light many times in many directions. Also, the surface of Earth has reflected and scattered the light. All this scattering mixes the colors together again so we see more white and less blue.
Sunsets are orange-red because in the evening, with the sun low on the horizon, sunlight must pass through more atmosphere to get to your eyes, and only the red light can make it all the way through. The shorter wavelengths have all been scattered toward the ground in the part of Earth where it is still daytime.