The color of the Sun that we perceive from Earth's surface is primarily influenced by the Earth's atmosphere. The Sun itself emits light in a broad spectrum of colors, including all the colors of the rainbow. However, when sunlight passes through the Earth's atmosphere, it undergoes scattering, which affects the color of the light that reaches our eyes.
The phenomenon known as Rayleigh scattering is responsible for the blue color of the sky during the day. This scattering process scatters shorter wavelength light (blue and violet) more than longer wavelength light (red, orange, and yellow). As a result, the blue light is scattered in all directions, creating the blue appearance of the sky.
When the Sun is near the horizon, such as during sunrise or sunset, its light has to pass through a larger portion of the Earth's atmosphere. This path lengthens the journey of light and causes more scattering. As a result, much of the blue and violet light is scattered away, and the longer wavelength colors, like red, orange, and yellow, dominate the scene. This is why the Sun appears more orange or yellowish during sunrise and sunset.
So, the color of the Sun in the sky appears yellow during most of the day because the shorter wavelength blue light is scattered away by the atmosphere. However, it's important to note that the color perception may vary depending on atmospheric conditions, such as pollution, dust, or clouds, which can further scatter and absorb light, altering the appearance of the Sun.