1. This basically never happens.
2. Don't compare to letting the money sit under a matress. Insteaad, compare with other investments.
Buying a lottery ticket doesn't make sense when measured purely in terms of profit, even when the expected profit is non-negative.