Q:

What is the purpose of the sugar in ketchup?

Most ketchup recipes - even homemade ones - include several tablespoons of sugar.  Commercial ketchup often has lots of high-fructose corn syrup.  What purpose does all of this sugar serve in a ketchup recipe?

A:

High fructose corn syrup is a preservative. While sugaring your ketchup is good for flavor, HFCS is great for shelf stability, as is the vinegar. 
The reasons you typically see HFCS in American Ketchups is that it is (1) heavily subsidized and domestic and cheap, (2) farmed by the same companies making the tomatoes, and (3) a preservative. Also, it helps to improve flow while maintaining viscosity.
Sugar generally can be used to cut the acidity in a tomato dish without inhibiting the taste or outshining the tomato. My stepfather had digestion issues with high acidity meals and swore by a teaspoon or two of sugar to help aid the stomach issues. Likewise, the acidity of ketchup may well be mitigated by all the sugar.

A:

Everyone who likes ketchup surely likes the sweet and tangy taste it always has, so in some sense the question's a bit circular.
But I imagine part of the reason people started making it that way is that the sweetness helps cover up the sourness, so it can contain more vinegar (which helps preserve it) without tasting awful.

