Never a good idea. Unless you win. Ask the recipient of $100m tax-free whether or not it was a good idea to buy a ticket.
I don’t buy lottery tickets, but as much as the chance is so ridiculously small that you might as well burn the ticket as soon as you buy it, that doesn’t stop people from winning.
In the UK it’s tax free, anyway.