The average American household spends $665 per year playing state-run lottery games. There is a long-standing debate as to whether these lotteries are a regressive “tax on people who are bad at math” or a “win-win” that generates both consumer surplus and government revenues. We study optimal lottery policy through the lens of optimal taxation, where lotteries are a taxed good whose consumers may be subject to behavioral biases. We derive new sufficient statistics formulas for optimal pricing and attributes of a government-provided good. We then estimate the key parameters using lottery prizes and sales data and a large new nationally representative survey. Individual-level lottery expenditures are highly correlated with survey measures of innumeracy and poor statistical reasoning, but our observable measures of behavioral bias statistically explain only about 15 percent of lottery purchases for the average household. We estimate that lottery demand is highly responsive to ticket prices and jackpot amounts, but not to smaller prizes. Using these empirical moments, we calibrate a structural model of lottery demand. In the model, lotteries are indeed a welfare-improving “win-win,” and the optimal implicit tax is similar to the current norms in U.S. states.