The reason why you shouldn't put warm food in the fridge is because the warm food can raise the internal temperature of the refrigerator.
When the internal temperature of the refrigerator increases from the warm food it puts other food at risk of being in the danger zone by potentially causing bacteria to grow rapidly.
Before placing food in the refrigerator it's always best to allow the hot or warm food to cool down to room temperature before refrigerating it for proper food safety.
You can eat 5 day old leftovers as long as the leftovers are still actually good and has no bad smell, mold or bad taste.
If the 5 day old leftovers were kept refrigerated then they are often safe to eat depending on what type of food it is.
If frozen the 5 day old leftovers are still very safe to eat and can even be good up to a year frozen.
Raw meats tend to last 3 days in the refrigerator and a year or longer in the freezer.
For cooked meats the cooked meats tend to last 5 to 7 days in the refrigerator before going bad.
And other cooked foods such as spaghetti, noodles, pizza etc tend to last a week or 7 to 10 days as well.
Just make sure the 5 day old leftovers or other leftovers still smell good and have no mold growth or slimy texture and they will be safe to eat.
If you're in doubt then it's best to throw the leftovers out.
But most leftovers last 5 days or longer and are often safe to eat depending on the food type.
I keep many leftovers for 5 days to 10 days in the refrigerator and have eaten them after that time but if I plan to keep any leftovers longer than 5 to 10 days I freeze them to make them last longer.