I never buy lottery tickets or scratch cards (though I love sports betting and casinos), however my father does buy a lottery ticket every week.
He's retired, and has enough money to live fine - he owns the flat he lives in, he has enough money to pay for his £100/month TV/internet package, to smoke a pack of cigarettes a day, and to buy whatever food he fancies without thinking about what's cheaper to eat.
He has a choice of living like that and accepting that's how the rest of his life will remain, or spending a tiny amount each week and having a dream of becomming a millionaire. He's not an idiot, he knows the odds are against him, but his buying lottery tickets doesn't have any impact on his lifestyle, and it lets him imagine that one day he might win big.
He wouldn't notice any difference in his financial situation if he stopped buying the tickets, so really the only downside is that, if he keeps buying them over a twenty year period, the inheritance that comes to myself and my two siblings when he dies will be a bit less. But if you think that way, his quitting the lottery would make a far smaller difference than if he didn't subscribe to extremely expensive sports channels, if he didnt spend £40/week on cigarettes, and so on. I'd far rather see him enjoy his money than save it for my sake - I'll get by fine either way.
Sure, for some people the amount they spend on lottery tickets does take away from money they could spend on other stuff, but there are people who are well off enough to be able to afford the cost, without being so well off that winning the lottery isn't a dream they enjoy having.