It might seem an obvious question, but the sun is in fact white. It appears yellow because the Earth’s atmosphere scatters blue light more efficiently than red light, and the resultant deficit of blue light gives the sun a yellow tinge. The effect is more pronounced at sunset and sunrise – when the blue light is scattered by a ‘thicker’, less perpendicular portion of atmosphere – which is why the sun often appears red or orange at these times of the day.
Source: https://www.sciencefocus.com/science/what-colour-is-the-sun/