The sun is is necessary to food chains, because it gives plants the energy to make their own food.
Almost all life on earth gets its energy from sunlight, either directly or indirectly. The earliest forms of life probably did not, and there are still forms of life that might not, but at some point, living things began to use the energy in sunlight to convert available chemical compounds that could be stored and later reused to make other chemicals for growth, reproduction, repair, and so on. These were probably ancestral to cyanophyta, and, in fact, to all green plants.
Some plants, vegetarian animals, fungi, and various bacteria consume either living green plants or those plants when they have died and/or decomposed to some extent. Omnivores are animals that do this and also eat other animals to some extent. Carnivores eat other animals. But animals that eat other animals are getting their energy indirectly from chemical compounds that depended in one way or another on plants converting sunlight.
When all these things die, they are eaten or decompose and the chemicals in them go through the cycle again.
But the sunlight is the original source energy for most living things.
There are living things that consume such things as hydrogen sulfide from deep sea thermal vents. Even so, it is hard to imagine that any of these things would be completely free of chemical compounds influence by sunlight at one time or another.