Sunlight comes to us in a full spectrum. When the sun reaches the Earth, the light scatters as it hits molecules in the atmosphere. This causes a prism effect, resulting in a spectrum of colors. In the visible range, reds are a higher wavelength than blues. Light with lower wavelength is absorbed and scattered by molecules. Thus, blue light is scattered more than reds. This makes blue appear everywhere in the daytime sky, when the light takes the most direct path.
So what happens during sunrise and sunset to cause different colors? When the sun is a lower angle, it travels further through the atmosphere. More blue light is scattered away, leaving the higher wavelengths of light. The higher wavelength light reflects in the atmosphere, and it travels further. The reds and oranges are now visible.