50 percent of the Dreamliner is composite, including major structural elements like the fuselage, wings, and tail. One seats 1 passenger, the other 300. The 787’s pricetag is $150 mil per plane, the F-22 is currently running $361 mil per plane. I hope the disparate prices reflect the F-22 being a more robust airframe, although I doubt it.
System costs are most of the reason. Airliners can install off-the-shelf avionics and flight controls that are identical, or almost identical, as other aircraft. While the various systems in fighters are very unique and require development from scratch. I think the F-22 in particular has some flight control techniques that are very unique and undoubtedly took a large effort to develop.
We don't build the best warplanes in the world by being cheap.