The light coming from the sun is made of many colors, each of which has a different wavelength. The atmosphere affects how each color of light passes through, as the light waves encounter molecules, small water droplets and bits of dust.
Blue light has a short wavelength, and the particles in the air scatter it around, making the sky appear blue. Red light has a longer wavelength, which acts more strongly and is not scattered as much.
Sunsets are red because in the evening, the light has more atmosphere to pass through to get to your eye, and only the strong red light can make it. The atmosphere in this illustration is exaggerated in relation to the Earth to show the difference.