Renewable energy muscled out coal to become Germany’s biggest source of electricity for the first time last year, helped by a surge in solar panel installations and coal-plant closures.