Lego is investing £310m to make its products more sustainable after letters from young customers.