Other than the high risk/high reward nature of the Greataxe, explained in ravery's answer, the Greatsword is usually the better option.
Mechanically, there are some ways to take advantage of the inherently higher damage die of the Greataxe though.
- A Barbarian's 9th level ability, Brutal Critical lets him roll one additional weapon damage die, on top of the normal extra dice gained from a critical hit. At higher levels this bonus increases to two and eventually three extra dice.
- The Half-Orc race has the Savage Attacks trait that gives a similar effect in allowing you to roll one your weapon's damage die one additional time when getting a critical hit with a melee weapon.
To make an example of how this would actually play out, I'll use the Barbarian's ability.
Example:
Level 9 Barbarian
Greatsword: 2d6 + 2d6 (crit) + 1d6 (extra weapon damage die) = 17.5 + relevant ability modifier
Greataxe: 1d12 + 1d12 (crit) + 1d12 (extra weapon damage die) = 19.5 + relevant ability modifierLevel 13 Barbarian
Greatsword: 2d6 + 2d6 (crit) + 2d6 (extra weapon damage dice) = 21 + relevant ability modifier
Greataxe: 1d12 + 1d12 (crit) + 2d12 (extra weapon damage diedice) = 26 + relevant ability modifierLevel 17 Barbarian
Greatsword: 2d6 + 2d6 (crit) + 3d6 (extra weapon damage diedice) = 24.5 + relevant ability modifier
Greataxe: 1d12 + 1d12 (crit) + 3d12 (extra weapon damage diedice) = 32.5 + relevant ability modifier
As you can see, the average damage of the Greataxe exceeds that of the Greatsword and at higher levels the difference is significant.
Now, a Half-Orc Barbarian that can consistently score critical hits would be a thing to see.
The problem is that this advantage that the Greataxe has over the Greatsword, only comes into play when a Barbarian and/or Half-Orc rolls a critical hit. A critical hit is rare on its own and for the Greataxe to outperform the Greatsword, you need a specific class/race.
On the other hand, as you mention, the Greatsword has a higher minimum damage, slightly higher and thus more reliable average damage and benefits more from Great Weapon Fighting, making it more preferable under most circumstances.