I think it's more so there is a chance to come out ahead. E.g., everyone sitting on a pokie machine absolutely knows in the long run, the casino wins out. However they are hoping they are the 1/million that gets the jackpot and "beats" it. The same reason people buy lottery tickets I guess.
Other people simply like the social aspect of a lot of games (craps, poker, blackjack, roulette) and the excitement/thrill of seeing some big winners. You know in the long run you are losing X%, but still go to burn hours and have some fun.
The entire lure of gambling is that some players can make money. The house always plays that up.
But if the house always wins, that hope they're selling disappears.