It's as optimal as you get with a melee fighter - with the understanding that fighters and melee re an unoptimised in general because 5e mechanics are hostile to builds melee and STR builds.
It is optimal for doing damage as a melee fighter if the caveat about magic weapons applies (and it almost never does). GWM alone is a far better choice generally. Also doing optimal damage is not the same thing as being an optimal build.
With all this keep in mind that a non-magic melee character itself is not an optimal build. If you are playing a melee character without spells or magic you are already gimping yourself significantly.
Plus just because it optimises for a different pillar of gameplay that you do, doesn't mean it's bad or unoptimised.
But it does not even optimize the combat pillar, it optimizes damage (which is not the same as combat) for someone who already chose a compromised weakish build.
If you really want to optimise Fighter it's Fighter 2 / Wizard 18
.
At 20th level a straight single class Wizard will be better in melee if optimized for melee because of the extra 6th level slot and thereby extra Contingency.
This 2/18 mix is probably better at some earlier levels for melee and it is ironically competitive with a 20th level Wizard as a control caster due to action surge. But when it comes to melee, a 2F/18W won't keep up with an optimized 20th level Bladesinger.
If you are going to multiclass a hard melee Wizard and expect to be as good at 20th level, the only viable choices IMO are Sorcerer 2 and Cleric 1 or 2. When I say hard melee I mean a character who is going to melee tank every fight, not a Gish that is going to do some control, some AOE and some melee.
I have experience playing both a 20th level Halfling melee Wizard (Bladesinger 18/Death Cleric 2) and a 20th level Strength-based melee Shaddar Kai fighter. Of these two, the Wizard was better at melee.
FWIW my 20th level fighter did not have GWM or PAM. At 20th level she was using mostly a Flaming Maul or a Great Club that functioned like a Mace of Terror. She also took the Mage Slayer feat as her last feat, mostly because it was near the end of the campaign and we knew we would be facing Vecna.
If someone is doing something that is discouraged by the rules (trying to use a low ability score to attack or cast with, running in to rooms without checking for traps), that's a different story.
Strength builds are discouraged by the rules.