Generally,you should refrigerate any raw food or any heated, prepared food that has moisture content. You should refrigerate heated food just as soon as the temperature reaches room temperature (only because hot foods would ruin the refrigerator or raise the internal temperature ruining other foods in the refrigerator).
Typical room temperature can begin breeding bacteria at worse or fermenting food which ruins the flavor. Try leaving peeled fruit, blended berries with some sugar overnight vs. refrigerating these to see what I mean! And the warmer the room temperature, the higher the risk.
Without exception, any food containing raw eggs or mayonnaise should never be allowed to remain at room temperature for more than 2-3 hours max This is because raw eggs -in any form- are a breeding ground for bacteria. I would extend this rule to condiments as well (ketchup, mustard).
Foods containing fish, poultry, red meat, sauces should be refrigerated as soon as possible. It's safer to use that rule than to risk illness from food contamination/poisoning.
There are some exceptions where you could leave unrefrigerated up to 24 hours, max
a) Foods with very high sugar content (think Japanese pickled ginger, hard candy,jams, maple syrup although the latter recommends refrigeration, particularly true for >24 hours once opened ) or
b)high acidity or saltiness (think pickles in brine, soy sauce, capers in salt), or
c) very liquid (chicken stock, vegetable stock which has been boiled for a long time and solids removed)
Dry ingredients, no moisture such as spices (lack of moisture impedes bacteria growth)are fine without refrigeration, as are processed food whose label does not explicitly state that refrigeration is necessary after opening.