Foods that are in containers with lids should be microwaved with the lid off or at least partially open and vented to allow steam to escape.
If the food is kept covered with a lid the container or whatever the food is in with a lid will build up pressure and can explode open and make a mess.
Having the lid open allows the steam to escape.
The reason you should allow the food to sit a few minutes after microwaving is to prevent being burned, and ensure even cooking and food safety.
Microwaves heat food unevenly in most cases and allowing the microwaved food to sit for a few minutes allows the remaining heat to redistribute through the food and ensures an consistent and safe temperature.
Taking food out of the microwave too soon can also cause burns as well.
After microwaving food you should allow and let the food sit for 1 to 3 minutes to cool down enough before removing it as it will often be really hot and could burn you.
I allow food to cool down for at least 3 minutes unless I cooked it longer and sometimes the food may need to cool down for 5 to 10 minutes before I remove it from the microwave.
It is not OK to leave food in the microwave overnight as the food can grow bacteria and go bad and cause food poisoning.
Even cooked foods left in the microwave overnight can cause food poisoning and grow bacteria.
After cooking the food in the microwave you should either eat it or refrigerate any leftovers if not eating it within a few hours.
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.