1. Those who do it for entertainment, fully (or mostly) conscious that they are almost certainly throwing their money away
2. Those who see it as a "voluntary" tax to help a good cause (typically education/public schools), like a 50/50 raffle
3. Those who are mathematically challenged and don't really understand probabilities
Not sure what is the split among these people, but I've met them in all three categories. Some are a combo (typically 1&2, but maybe even 1&3 or 2&3 also at times).
Personally, I've never bought a lottery ticket in my life.