The argument that lottery tickets are bad value is based on the expected (mean) return.
For example, for every $2 ticket, you might get $1 in prizes on average.
On average, you're losing on every ticket.
However - this completely fails to value the fact that you have massively increased the standard deviation of your return, so although your expected return is $1, there is some chance that you'll get $1million.
We recognise that reducing standard deviation on negative events has value.
For example, your expected return on your insurance payments of $1000 is less than $1000. However, you have reduced the standard deviation of the expected return and (hopefully) negated the possibility of losing $1million.
On average however - you lose money whenever you buy insurance.
If we are willing to pay (on average) to avoid losing $1million, then it is is equally logical to pay (on average) for the opportunity of gaining $1million.