Premise I'm starting with the following assumption: two-weapon fighting and great weapon fighting both occupy two hands, so their output should be relatively even. Different, maybe, but even. In practice, great weapon fighting is more flexible: you can take a hand off your greatsword to use potions or cast spells, and you only need one magical greatsword, not two magical shortswords – but let's be kind.

Rogues

Rogues are probably the best-balanced for TWF, because while the damage boost is relatively small and Cunning Action gives them a plethora of competing bonus actions from the get-go, the reliance on Sneak Attack for damage means that a second chance to hit never stops being worth it.

Barbarians

Barbarians run pretty even, with TWF/GWF dipping only slightly up or down over each other as the per-hit Rage bonus balances out the increasing potency of their critical hits.

Except that Barbarians rely on Rage to maintain TWF damage, and entering Rage is a bonus action. This means that you always lose 1/10 turns of extra TWF damage. You then miss out on more, because every Barbarian subclass bar the Ancestral Guardian uses bonus actions for its features. And you miss out on even more if you run out of Rage.

Paladins

Paladins don't get the Two-Weapon Fighting Style, but once the per-hit damage bonus of Improved Divine Smite kicks in, TWF is actually left only slightly behind. Divine Smite also lets them selectively boost a single attack's damage, so TWF's boosted hit chances are even more useful.

The Barbarian problem returns here, however. Almost every Paladin spell worth casting uses a bonus action, and more than half of the Oaths have bonus action features. As your turn becomes more crowded with options, the average TWF damage dips and dips.

Granted, the Paladin isn't "meant" to be a dual-wielder, but these problems reflect on any analysis of the Ranger, too.

Fighters

Fighters have it the worst, because they get up to four attacks anyway – an extra one is a drop in the bucket.

It doesn't help that the Two-Weapon Fighting Style isn't a per-attack damage bonus that can scale like its peers. It's a flat +3-5 dpr boost, and eventually loses out to Great Weapon Fighting even before factoring in the latter's effect on critical hits, Maneuvers, etc.

Once again, competition for bonus actions digs an even deeper grave for TWF. Second Wind is a choice between a turn's damage boost or a turn's healing, and every Fighter subclass except the Champion uses bonus actions, often in pretty fundamental ways. Once you factor in feats, the GWF will inevitably grab Great Weapon Master or Polearm Master, to reap the benefits of TWF anyway.

It doesn't help that the all-important Action Surge doesn't give you a new bonus action, leaving TWF high and dry.

Problems

So we can see two consistent, unique problems with TWF:

1) TWF occupies a bonus action that is needed for more valuable features. No other basic weapon type does this.

2) TWF fails to scale its damage with additional attacks. No other basic weapon type does this.

As a result, TWF becomes less valuable (2) and more expensive in terms of opportunity cost (1) as time goes on.

Bonus Action Cost

Classes (and feats) in 5e all assume that the PC's bonus action is not currently in use. This is because by default, it does nothing: there is no core rule that allows the use of a bonus action, so it's free real estate in design terms.

The sole exception is TWF. This forces anyone who wants it to choose between TWF and features (Rage, Second Wind, etc) that clearly weren't meant to preclude dual-wielding.

This problem can be solved in two ways:

1) Remove the bonus action cost of TWF. This is simple and straightforward, but will require making TWF less powerful in its basic form.

This is simple and straightforward, but will require making TWF less powerful in its basic form. 2) Make TWF worth a bonus action. Rogues are the best-balanced class for TWF, because their Sneak Attack feature means that an extra chance to hit remains valuable up to 20th level. However, making TWF valuable enough to merit a bonus action even in the face of competing features, spells, and feats, across all levels and martial classes, would be extremely complex.

Lack Of Scaling

Almost every martial class in 5e increases its damage by increasing its number of attacks. This means an extra attack from TWF becomes comparatively less valuable as the character progresses. However, the common house rule of giving even more attacks to TWF at higher levels is a trap: it causes per-hit damage to soar out of control.

This is a problem that affects different classes differently. Rogues and martial Clerics don't use extra attacks, while Paladins and Barbarians lean on per-hit damage bonuses, but Fighters focus on Extra Attack as a damage source.

This problem can be solved by changing TWF to scale with attacks.

This scaling can and should be tied to the TWF Fighting Style, as that is the Fighter's focus and will not overly impact classes who cannot access it (Paladin, Barbarian) or have only two attacks (Ranger).