This is true, but the kind of value being provided is different. Peace of mind is not the same thing as entertainment.
Only a fraction of the consumers come out ahead if we only consider monetary value. But the whole reason insurance and the lottery exist in the first place is that there are other kinds of value besides monetary value. In the case of insurance, it's peace of mind. In the case of the lottery, it's whatever entertainment value comes from being able to visualize yourself winning, even if your chances of actually doing so are tiny.