Is there an economic analysis of the rationality of buying lottery tickets?
There are definitely economic justifications for playing the lottery, even if all (I hope) players understand that it is unlikely to pay off.

One such justification is that what you actually buy when purchasing a lottery ticket is the fantasy of winning.

Here are a few sources. Lotterys are relatively well understood in economics.


The Economics of Lotteries: A Survey of the Literature(pdf)  - is an excellent article covering basically your entire question. It discusses the microeconomic forces at play, particularly income elasticity and risk aversion.
This source (note: this is now a dead link) has some excellent lecture notes on the market for risk. I recommend it highly. Some basic points are:


people don't want actuarialy fair games, often they would decline a coin flip with a payoff of \$1mil for a win and a cost of \$1m for a loss. Also, an actuarialy favourable game isn't necessarily desirable. If the payoff was \$1.1m people would still decline the game as the cost is just so high. In that sense, a lottery has an advantage. The payoff can be huge but the cost in the event of losing is almost negligible.

Lastly, this source is an article from the NY times. Definitely relevant, highlighting similar points to the first two articles but is a lot more accessible.