I asked chat-gpt the same question, and this is her answer:
The energy of light that is redshifted due to the expansion of the universe doesn't disappear, it is simply transformed into other forms of energy. Energy is indeed conserved, as stated by the law of conservation of energy.
When light travels through a stretching universe, its wavelength increases, leading to a decrease in frequency and energy. This is known as redshift. The energy lost by the light is then transformed into potential energy between the expanding space and the photon.
In this case, the loss of energy from the photon is balanced by the increase in gravitational potential energy of the universe. This conserves the total amount of energy, even though the energy of the photon has changed form.
In summary, the energy of light that gets redshifted due to the expansion of the universe doesn't disappear, it is transformed into other forms of energy, such as potential energy, conserving the total amount of energy. *
I also found other posts asking the same question and its answers.
Can anyone tell me which is correct?