Light entering the Earth's atmosphere gets scattered by coming in contact with atmospheric particles. This phenomenon is called the scattering of light.
As per Rayleigh Scattering, the amount of scattering of light is inversely proportional to the fourth power of the wavelength of light, that is, light of longer wavelength gets scattered less and travels more distance whereas light of shorter wavelengths gets scattered more and travels less distance.
During the sunrise and sunset, the rays have to travel long distances as the Sun is near the horizon.
While all the other rays (having shorter wavelength) get scattered more, red, having the longest wavelength gets scattered the least and therefore, travel the distance reaching our eyes, thus, making the sun look red.