The sun gives plants energy and allows them to grow. Plants are eaten by animals. At the end of their lives, plants and animals both decompose, which puts bacteria in the soil which are needed for the cycle. Also don't forget
legumes, which fix nitrogen in their roots and put it in the soil - they use the sun's energy to grow too. Without energy from the sun, none of this would happen.