Quoted By:
Megas are a better gimmick than dynamaxing and ESPECIALLY Z-moves. A better gimmick, but a gimmick nonetheless.
The issue is that GF doesn't like changing the base stats of pokemon very often, or getting rid of bad abilities. I'm guessing it's because they don't want to impeach on their identity or whatever, but they still want to give them a new identity. Thus, mega-evolution.
Megas also only function if the trainer and pokemon share a strong bond, enforcing the cliche but workable aesop of "friendship gud," unlike Dynamax which is something that can just be done to any pokemon. It's just not as fleshed out lorewise compared to mega-evolution or even Z-moves because Gen8's story was shorter than my pp.
Plus, megas have clearly had a greater impact on the series than Z-moves (not comparing it to Dyna yet cause it's still relatively new, though I'm not optimistic for its future). People are still sperging for more megas, but how many people are asking for Z-moves?
In short: Mega Evolution, like any gimmick, is not strictly necessary, but it's at least a better gimmick than its competition, but it's flashy, cool, and enforces the classic friendship aesop, which goes great with pokemon. It's had a more lasting impact on the series. In short, it's as good as gimmicks get for pokemon, and it's a damn fine addition.