Is playing the lottery a wise investment? --Probably not.
Is playing the lottery an investment at all? --Probably not though I'll make a remark on that further below.
Does it make any sense to play the lottery in order to improve your total asset allocation? --If you follow the theory of the Black Swan, it actually might.
Let me elaborate. The Black Swan theory says that events that we consider extremely improbable can have an extreme impact. So extreme, in fact, that its value would massively outweigh the combined value of all impacts of all probable events together. In statistical terms, we are speaking about events on the outer limits of the common probablity distribution, so called outliers that have a high impact.
Example: If you invest $2000 on the stock market today, stay invested for 20 years, and reinvest all earnings, it is probable within a 66% confidence interval that you will have an 8 % expected return (ER) per year on average, giving you a total of roughly $9300. That's very much simplified, of course, the actual number can be very different depending on the deviations from the ER and when they happen. Now let's take the same $2000 and buy weekly lottery tickets for 20 years. For the sake of simplicity I will forgo an NPV calculation and assume one ticket costs roughly $2. If you should win, which would be an entirely improbable event, your winnings would by far outweigh your ER from investing the same amount.
When making models that should be mathematically solvable, these outliers are usually not taken into consideration. Standard portfolio management (PM) theory is only working within so called confidence intervals up to 99% - everything else just wouldn't be practical. In other words, if there is not at least a 1% probability a certain outcome will happen, we'll ignore it. In practice, most analysts take even smaller confidence intervals, so they ignore even more.
That's the reason, though, why no object that would fall within the realms of this outer limit is an investment in terms of the PM theory. Or at least not a recommendable one.
Having said all that, it still might improve your position if you add a lottery ticket to the mix. The Black Swan theory specifically does not only apply to the risk side of things, but also on the chance side. So, while standard PM theory would not consider the lottery ticket an investment, thus not accept it into the asset allocation, the Black Swan theory would appreciate the fact that there is minimal chance of huge success.
Still, in terms of valuation, it follows the PM theory. The lottery ticket, while it could be part of some "investment balance sheet", would have to be written off to 0 immediately and no expected value would be attached to it. Consequently, such an investment or gamble only makes sense if your other, safe investments give you so much income that you can easily afford it really without having to give up anything else in your life. In other words, you have to consider it money thrown out of the window.
So, while from a psychological perspective it makes sense that especially poorer people will buy a lottery ticket, as Eric very well explained, it is actually the wealthier who should consider doing so. If anyone. :)