The lottery is paid for by those who all have an equal chance of winning that prize. Also, the profits from lotteries are usually spent on social funds etc.
I feel more conflicted about thr fact that it preys on addiction and those who buy the most lottery tickets are often those who can least afford them. I find that much more grotesque than a random person getting very lucky, but to each their own.
In the US, close to half of the winnings do go to the lottery, plus a portion of each lottery ticket usually goes to fund some government agency. Schools, programs for the impoverished and disenfranchised, etc.
The real question, in my opinion, is if you are willing to spend that much money on a ticket, why aren't you willing to spend that much money on just outright funding government programs? Imagine if 100% of what someone paid for a ticket went to programs for the disenfranchised? That could make real difference.
Probably worth noting that, at least in places like Texas, they take the funds from the lottery, allocate it to school, and then take the same amount of money out of schools to fund whatever bullshit they want.