why do wings have high aspect ratios on commercial airliners?
Aerodynamically, you want the aspect ratio to be as high as it can be (for a given wing area). You want infinite wingspan, because that results in no induced drag. But that is not very practical at airports, and a bit heavy.

Structurally, you want short stubby wings because they have a very low bending moment. In fact structurally, you want zero wing span. But that is not very practical at take-off time.

As always, aerodynamic desirability implies structural objections, and vice versa. The aerodynamicists need to strike a deal with the structures engineers: a balance needs to be found. As long a wing span as possible, with as thick a profile as possible, using a material that is as light as possible. So a long wingspan is desirable and is only limited by structural constraints: as you say, at a certain point the longer wing span's increased weight will offset any aerodynamic advantages.

In aluminium, the optimum was reached over the course of a few decades. But now there is a new material with a better strength/weight ratio: composite carbon fibre. Carbon is much stronger than aluminium, and it is woven in a matrix of resin, with most wires running in the direction of highest stress. With carbon fibre, even the direction of material strength can be optimised. And the B787 and A350 have even higher aspect ratios than the B777.