Prior to takeoff from fields above 3000 feet elevation, the mixture should be leaned to give maximum RPM in a full throttle, static runup.
Ironically, although this procedure may well result in the engine delivering around the maximum power it can in the circumstances, that outcome may not be optimal.
When you go ‘balls to the wall’ on a properly set up, normally aspirated piston aero engine at sea level in standard conditions, the engine is
not delivering the
maximum power that could be delivered by the engine. It’s actually (or should be, if the engine’s set up properly) richer than the mixture that would deliver maximum power.
You could suck more power out of the engine, by leaning. But that would be bad.
The optimal ‘high power’ sea level settings for normally aspirated piston aero engines are richer than the mixture that would deliver maximum power. That’s for the good of the engine.
At aerodromes at really high density altitudes there’s probably no mixture setting that could result in damage to a properly set up, normally aspirated piston aero engine. But at 3,000 to around 6,500’, badness can happen if operating for extended periods at the mixture that produces the maximum power output for the engine.