A great question!
It actually has to do with the best lift:drag ratio. As the name implies, it is the amount of lift generated by a wing or aerorfoil compared to its drag. A ratio of L/D indicates aerofoil efficiency. Aircraft with higher L/D ratios are more efficient than those with lower L/D ratios.
Because of the relationship between the wing, the shape of it, and how that produces lift, the maximum L/D ratio occurs at one specific AoA (Angle of Attack). If the aircraft is operated in steady flight at the L/D max ratio, then total drag is at a minimum. Any AoA lower or higher than that producing the maximum L/D ratio reduces it and consequently increases the total drag for a given aircraft's lift.
Having said all that, the B777 will operate at around 2.5º nose up in the cruise. So when the beds are laid flat they are angled slightly down to compensate for this nose up attitude and is then seen as being 'flat'.
View attachment 93632