The lottery is one of the few ways they could escape this debt spiral - if they could get a positive bank balance, they could begin to accumulate assets. That's not to say most people are able to do it, because suddenly having a lot of cash without financial literacy is dangerous. There's also a strong impulse to help out the people around you, which is tough because if the money is spread too thin none of the beneficiaries escape the debt cycle, they just reduce their balances slightly and then continue sliding downwards.
All that to say, playing the lottery is not stupid, it's a rational response to a society that's designed to drain the wallets of the most vulnerable for the benefit of the wealthy.