During sunrise or sunset, the sun is near the horizon. The sun's light has to travel the longest distance through the atmosphere. As it travels most of the colors are scattered away according to Rayleigh's criterion
According to the Rayleigh's criterion, the intensity of scattered light is inversely proportional to the fourth power of the wavelength if the size of the scatterers are of the order of the wavelength of light. Air molecules have their size of this order.
Red reaches our eyes since it has the longest wavelength.