If you know the 787 wing flex is much greater than the 747-8's wing why can't the 747-8 have a greater wing flex
The reason is twofold: The materials used and the high aspect ratio.
The 747-8 primarily uses advance aluminum alloys, while the 787 uses carbon composites.
The carbon composites flex more compared to the aluminum alloys. This can be achieved because the carbon fibers are anisotropic and their properties can be tailored in each direction.
The yield strain of the aluminum alloys used in aerospace is ~1%, while that of the carbon composites is about 50% higher, ~1.5%.
These material characteristics mean that the carbon spar can flex more compared to the aluminum one. This effect is magnified by the high aspect ratio of the Boeing 787.
The 787 wings are able to take this flexing in part because of the excellent fatigue properties of the Carbon composites used. See this question for a very good discussion on the causes and effects of wing flexing in 787.