The real issue with the 747 is people will take a point to point route if at all possible. Worse, flying a small plane point to point is cheaper for the passenger than flying 2 747s. If you live in Lincoln NE - sorry your city is too small to get direct flights to anything but close major hubs (even then odds are you drive to nearby Omaha thus further reducing demand options). However if you live in a Larger non-hub city airlines can undercut each other by just doing direct flights to other large non-hub cities.
The 747 was at its most efficient when flying long haul routes, like overseas. The 747 was immensely profitable for Boeing for several decades. Every sale was a giant chunk of cash dumped on the company. But none of that would have happened if the 747 wasn't also immensely profitable for the airlines.
True but small planes are profitable too even for long flights. They have to compete against the more profitable large ones but they do that by emptying the large ones. I want to get to a destination and if a small plane isn't much more money it is cheaper to not transfer at a hub and pay for the 2nd plane to where I want to be. More smaller planes can also fit my schedule which can save money.
there is a reason nobody flies the 747 anymore. It isn't profitable enough agaisnt the 777 and small planes which are cheaper to run.
Mostly it's about engine tech. A 777/787 or whatever can fit almost as many passengers as a 747, but has only two engines, burning less fuel and requiring less maintenance.
Back when 747 was designed engine tech wasn't there yet to build really big two engine airplanes. There was also the issue of ETOPS limits. The regulations on how far away from nearest airport you can fly with two-engine aircraft were stricter than today, so for many routes flying over oceans you needed more than two engines.
There's also the issue of cargo space. The 777-300 actually has a larger hold, about 11% more. Cargo is pretty lucrative so even passenger airlines like being able to devote some of their hold space to it.
Modern wings could be retrofitted to the 747. Maybe not completely, but the more important features. However there are a lot of other parts of the 747 that don't make sense, and so not enough buyers (if any!) would exist if they did.