Why do some foods need to rest before serving and others do not?
Because resting solves different problems depending on what is being cooked — and applying the meat rule to everything is why people rest things that get worse for it.
Roast and grilled meat. Resting lets the temperature even out and lets the muscle fibres relax so they reabsorb liquid that was driven towards the centre. Cut immediately and juices run out; rest and they largely stay. Carryover cooking also continues during the rest — a large joint can rise several degrees, which is why it should come out below target.
How long: roughly five to ten minutes for a steak, twenty to forty for a large joint, loosely covered. Wrapping tightly traps steam and softens any crust you worked for.
Baked goods. Bread should cool substantially before cutting because starch retrogradation is still setting the crumb; cutting hot bread gives a gummy texture. Cakes need to firm before turning out. Brownies and some tarts are deliberately cut cold.
Batters and doughs rest for a different reason: hydration and gluten relaxation. Pancake and Yorkshire batters improve because the flour fully hydrates and the gluten relaxes, giving a tenderer result. Pastry rests to relax gluten so it does not shrink.
Casseroles, curries and stews genuinely improve overnight, as flavours diffuse, fats redistribute and some harsh compounds mellow.
What should not rest:
Anything crisp — fried food, roast potatoes, tempura — which goes soft as internal steam migrates outward. Serve immediately.
Soufflés and anything risen with steam, which collapse.
Fish, which is delicate and needs only a minute or two at most.
Pasta, which continues absorbing and clumps.
Green vegetables, which dull and soften.
The underlying principle: rest when something needs to equalise, relax or set; serve immediately when the quality depends on a temperature or texture contrast that is actively decaying. Almost every case fits one of those two.