When the sun is overhead, then the light coming from the sun has to travel a relativity shorter distance through the atmosphere to reach us. During the shorter journey of sunlight, only a little of the blue color of the white light is scattered. Since light coming from the overhead sun has almost all its component colors in the right proportion, therefore the sun in the sky overhead appears white to us.
But when the same sun is near the horizon at sunset, the sunlight has to travel the greatest distance through the atmosphere to reach us. During this long journey of sunlight, most of the shorter wavelength blue colour present in it is scattered out and away from our line of sight. So, the light reaching us directly from the setting sun consists mainly of longer wavelength red colour due to which the sun appears red.