The sweetest tomatoes are underripe

Other commenters have touched on acidity or tang. I think acidity is a major factor in taste. I postulate (with no empirical evidence at all) that slightly unripe fruit that has maximum sugar content would also have excessive acidity, more than offsetting any additional sweetness that might be in place. As the fruit ripens further, the acid/sugar proportions come into optimal balance for what we perceive as the height of ripeness, even if the total sugar content has diminished. Further on in ripening, the balance goes off again, leading to the perception of over-ripeness. It’s the sugar/acid balance that makes for optimal flavor, not the most sugar.