Why are longer wings with foldable wingtips used on the B777X instead of lighter ones with original size?
This explanation is given here :

The wing of the 777X is based upon the design of the 787’s wing. It
has less of the sweep of the 787 but 10% more surface area (increased
from 4,702 to 5,562 sq. ft.). The re-shaping has led to a higher
lift-to-drag ratio, which(and) in turn increases usable fuel bulk from
320,863 to 350,410 lb. As a result, the type will have a range of over
14,000 kilometers (8,699 miles).
Boeing’s motivation for its including folding wingtips within the
design was not wholly steered by fuel economy. With a fully-extended
wingspan of 71.8 meters, the new 777X falls within the ICAO’s
aerodrome Code F. But with raked and folded wings (and a span of 64.8
meters) the type can comfortably arrive at gates designed for Code E.
Aircraft in this group includes the current 777.

So not only are they looking for more surface area and aerodynamic efficiency, they need to house more fuel to give it an extended range.