In many countries the state’s lottery earnings are earmarked to support charities.
https://www.national-lottery.co.uk/life-changing/where-the-money-goes
It is especially heritage and culture work that profits from that because they often don’t get the same amount of public attention as other charities.
While I don’t play the lottery myself, I don’t think anyone that does so (at least in a country like this) is wasting their money.