Ketchup contains tomatoes, vinegar, sugar, and spices, and its acidity helps preserve it naturally. That is why an opened bottle does not immediately go bad if left out. But being able to last for a while at room temperature is not the same as keeping its best quality for a long time.
Refrigeration helps ketchup stay fresher, keeping its flavor, texture, and overall quality more stable over time. It is especially useful if a bottle is opened and used slowly over weeks or months, since warmth and repeated exposure can gradually affect it.
Pantry storage can still work if the bottle is used quickly and kept in a cool, dark place. So in the end, the most practical answer is that the fridge is usually better for longer freshness and safety, while short-term pantry storage may be fine depending on how fast you use it.