You haven't specified a tech level, so I'll give a mix of options.
I think one of the simplest ways to do this would be to find some kind of volcanic activity, deep underground. Volcanic intrusion of molten rock into the lower parts of your caves provides heat, and even a little light. You'll want a shaft passing through the layers your people live on and up to the surface (or at least, somewhere it can safely vent large quantities of toxic gas). This carries the volcanic gases away upward to where they won't asphyxiate the people (or you can just have the magma on the other side of a wall, so the toxic gases are kept out - you just need the source of heat). The more important part, though, is that the rising warm air creates a strong flow that draws the air out of the tunnels. This means that fresh air is drawn in at the other end, so you can have this continual flow where fresh air is pulled in at the entrances away from the magma, and then the stale air is drawn up by the rising hot column near to the magma. You can do this with furnaces, but they need fuel which can be hard to come by underground, so living near volcanic activity is an attractive option. This is how termites keep the air in the deepest part of their nests breathable, except that they use the heat of the sun warming their termite mounds rather than furnaces or volcanoes.
Once you have the air situation sorted, you can also use the heat of the magma to allow something like the clusters of life around hot vents on the seabed, and hopefully that can be the bottom of a food chain that eventually produces something edible by humans. Probably from plankton-type things to siphoning sea-sponge type things to crab-like or fish-like things, and from there you're in more recognisable territory for a fish-based food source - kinda like real-world fish or oyster farms, but in vats deep underground. Seaweed gives you good options for "vegetables", and there are algae that have all sorts of beneficial properties. You can also use this for handling waste - sewage, food waste, even cloth and wood once it's been mulched down a bit; basically anything biological. Oysters are great at filtering water, so you can supplement whatever underground streams you're using for drinking water by filtering waste water. The heat of the magma also provides the option of distillation.
If you want, you could probably get some bioluminescent plants (or even creatures) so that you can get low-level lighting just by piping water from the vats through something transparent, and then the water will provide warmth and nutrients (or plankton, or whatever) for the glowing plants to live on. It's probably not bright enough to grow crops, although perhaps with lenses you could focus the light into small patches that could grow a plant or two, which might be enough to grow a few medicinal plants for your doctors. The warmth of the water also lets you spread the heat around and turn some of the cooler caves into places warm enough to live comfortably, so they don't have to cluster so tightly around the magma intrusions and can have a little more living space.
If you have the tech for it, the heat of the magma could be used in some kind of geothermal power (boil water, use the steam to spin turbines and generators, let the steam rise to cooler caves to condense, let the water trickle back down for re-use). That would give you electric lighting, and from there hydroponics and all the rest.