"But what about all the energy and carbon emissions to produce wind turbines and solar panels?"
They pay off the energy and carbon debt within a few months.
After that their existence prevents the continuous burning of fossil fuels for decades.
Data from @emberclimate