For many people, buying a lottery ticket is rational, in the sense of the Kelly criterion.
The Kelly criterion says that the strategy of maximizing expected value will lose 100% of the time to a different strategy. The most general form that I know of the winning strategy is: minimize your expected time to reach $X, for arbitrarily high values of X, eg $1M or $1B (ie, in the limit to infinity). Following this strategy will eventually beat any other strategy, 100% of the time.
For many people, the expected time to reach say $10 million is infinite: they simply cannot produce more than they consume, and in 10 years (or 100) they expect to be no better off materially than they are today. Any amount they try to save will eventually be used for some emergency (eg car breaks down, or health, or eviction/rent going up, etc).
Even assuming that the expected value of a lottery ticket is deeply negative, it is then Kelly-rational to buy lottery tickets, or more generally take a chance on any possible way of getting out of this equilibrium.
Of course I am handwaving away certain reasonable objections, and the argument can fail if indeed there is a chance of leaving the equilibrium otherwise, and the price of a lottery ticket is too high; but ultimately I believe the argument does apply to a not-insignificant percentage of buyers of lottery tickets.
This does hinge on the fact that in practice you can always "afford" to buy one lottery ticket per $period, yet you may not be able to save $2 per $period without ultimately having to raid the piggy bank for some emergency. So the lottery can be thought of as a creditor-/bankruptcy-/emergency-proof savings account
"No better off materially" is also something you cannot handwave. There is a limit. If someone gambled all of their money then they would be worse off materially, and quickly. They are not in equilibrium, which means your hypothesis requires some sort of lower bound.
This is a well-studied topic. https://link.springer.com/article/10.1007/s10899-010-9194-0 concludes:
> Empirical knowledge on lottery gambling has increased significantly over the past decade. Recent literature on lottery gambling involving numbers games, lotto, and scratch cards has provided three tentative answers to the question as to why people buy lotteries: some people do not behave in a rational way while gambling on lottery; lottery gambling is for fun; and lotteries are so common they are not viewed as gambling. Lottery gambling theories, classified into one that deals with judgment under uncertainty and another that deals with irrational beliefs, continue to be the theories of choice in lottery gambling research. Theoretical frameworks other than those of cognitive theories, such as social cognitive theory and theory of planned behavior, have been introduced in lottery gambling research. Dimensions of personality have also been found to relate to lottery gambling.
Your model does not include the "fun" part.
You can see that people in the lowest income bracket are the least likely to gamble, I'm guessing because they will be in a materially worse situation by gambling:
> The inverted U-shape distribution of lottery gamblers among five SES quintiles (low, 2nd, 3rd, 4th, and high) showed larger proportions of lottery gamblers in the 2nd and 3rd quintiles (70% each), whereas the low, 4th, and high quintile accounted for 61, 65, and 63% respectively (Welte et al. 2002; Table 2).