Way 1: It provides energy for producers.
Way 2: It provides weather.
Way 3: If we didn't have the sun, we would have no energy for producers, therefore, all the animals would die because the primary consumers would have nothing to eat, so they would die. The secondary consumers wouldn't have the primary consumers to eat. Then the tertiary consumers wouldn't have the secondary consumers to eat. Then the quaternary consumers wouldn't have any tertiary consumers to eat! So everyone and everything would die! (sorry for such a long answer, but hope it helps!)