What do you mean by here? A lottery is a form of gambling. By far, it's the biggest legal gambling in every country.
In most countries, lotteries are backed by a government. Some proceeds here are used in infrastructures, charities, and many more.
I agree with you, legal casinos are profitable just like the lottery because our government gets something from it. And the lottery company itself can assist just like medical and charity work.
As for the closure of illegal gambling in Thailand, it really should be shut down because it is illegal. And let them continue to operate legally and licensed gambling because even if they involve small gambling businesses, they will lose their jobs, especially if this is what they expect daily. It also depends on how the steps their government will take, whether the outcome will be successful. They just tighten the rules instead of closing them, just like having a limit or number of clients or customers, and schedule the opening and closing of the casino. Of course, followers must also adhere to the applicable laws or protocols and apply the discipline to themselves.