Investors have spent more than $2 trillion on clean-energy plants in the past decade and last year added more renewable capacity than ever before.