To balance the tomatoes' acidity.
Tomatoes are naturally acidic, and how sharp they taste depends on the variety, ripeness and season. Canned tomatoes or tomatoes picked before they're fully ripe can taste harsh or tinny. A small pinch of sugar doesn't make the sauce sweet; it rounds off that sharp edge so the tomato flavor comes through.
Taste first and add sugar only if the sauce needs it. Start with a quarter teaspoon for a big pot.
There are other ways to get the same effect. Long, gentle simmering mellows acidity. Sautéing grated carrot or onion adds natural sweetness. A knob of butter stirred in at the end softens the edges. Some cooks add a tiny pinch of baking soda, which neutralizes acid directly, but too much makes the sauce taste soapy.
Using good tomatoes, like ripe summer tomatoes or quality canned plum tomatoes, often means you don't need any sugar at all.