People have been arguing about the gap since the internet was a thing. In old school D&D it rarely came up because it was stupidly hard to play a Wizard, you didn't mind if the Cleric was strong as long as he brought the heals, and offensive spells were largely a joke at higher levels.
Nobody wants to admit that the melee monster they love to play is weak. And, in many games, depending on spell loadout, how the casters are played, and how well they support the melee, you might not even see a problem!
But casters are able to acquire silver bullets that neatly solve problems, and when the caster has their moment to shine, that's something non-magic classes can't do. Whether it's using Fabricate to quickly arm a village with weapons and armor, or using Guards and Wards to lock down a keep to prepare for a siege, or even just making sure the party can get a long rest without having to worry about random monsters or inclement weather- you rarely get that kind of influence over the narrative of the game as a "sword guy".
You can, but this is almost always relegated to skills. A Fighter should be able to train those peasants, a Rogue should be able to create traps to prepare the keep, and a Ranger and his animal buddy should be able to use their knowledge of woodcraft and bestial senses to keep a party safely hidden from threats while they sleep.
But these are usually ad hoc abilities that require skill checks. The caster can usually do the same thing with a single action. And even if it takes 10 minutes or an hour, they still don't have to roll dice. Their spell just works.