Tiny suspended particles in the atmosphere – and the gas molecules themselves – cause the light from the Sun to be split into its constituent wavelengths (this is called Rayleigh Tinytering). The shorter, blue wavelengths are scattered more, so the sky appears bluer the further from the Sun you look. At sunset, the sky at the horizon looks red because the light there is scattered least.