There's a simple answer: Offer a lottery with a high payout rate and flatten jackpots to the extent they don't cause a shift into other worse sorts of gambling. The total amount of money transferred to support government programs makes up less than 0.5% of total government revenue; it's trivially replaceable.
If we assume the main problem with lotteries is that they make some people poorer, we need to solve two things: The payout being less than the cost due to both high overhead and transfers and the payouts tending to concentrate wealth since even in a lifetime of play few win the largest jackpots.
One can't make them too flat because consumers like large jackpots which is why they've grown over time and become harder to win. Presumably there's a level below which consumers would switch to other types of gambling regardless of legality.
I assume that would reduce lottery proceeds significantly so is a nonstarter. I know the numbers, but I'm not so sure it's always illogical (in a human/emotional sense) and you get quite a bit if middle class people playing when the payouts are significant. YOLO
Sounds like NS&I 'premium bonds' in the UK. Expected rate of return is 1.4% (I think, something like that anyway) but it's paid as prizes monthly ranging from £25 to £1M - or no prize.
Increasing payouts should bring more players though it would be offset by eliminating the advertising that currently consumes some of that revenue. Flattening jackpots would have a negative effect but we just need to optimize for being above the point at which there's competition instead of maximizing lottery revenue.