Why does the boeing 747-8 have less wing flex than the 787?
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 aspect ratio of the 787 is about 11 while that of the 747-8 is about 8.5. This means that the wings are more slender and flex more for the same load.

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.