Most websites are not optimized well because optimization costs money and software engineers are expensive. There probably is not a market failure here.
Most web sites send a lot of data that is not for me, the user; it's for the website, to serve ads or track me or do other things that I either don't care about or would much rather they didn't do. The website had to make a conscious choice to include all that stuff; it's not as though it was already there and would have to be optimized out.
In other words, the problem is the most websites are optimized, but not for their users.