Aluminum foil does not make food warm. It can keep food warm longer by trapping the hotter air inside, which then serves as an insulator, and by preventing interchange of the hot air inside with cooler air. Aluminum foil itself conducts heat very well so it isn’t an insulator itself. Instead it is a barrier that limits the mixing of the hot air inside with the cooler air outside. If you wrap the food with cotton napkins first and then with foil it will stay warm longer simply because the napkin holds the foil farther from the food, creating more space for insulating air.
It’s simply insulating the food keeping the heat trapped closer to the food for a longer period of time. Kind of like insulation in your house helps hold the heat in winter and ac in the summer inside. But I’m a bit of a health nut so I will say that before covering food with foil, cover it first with a few layers of parchment paper, which is what I do. Aluminum is not good for your brain. It’s believed to be in part one of the reasons for alzheimers and dementia. Have you ever noticed the color change of the side closest to the hot food? The aluminum leaches into the food and you consume it when you eat that food.