In general insurance is designed to contain or negate your loss, but not to allow you to profit, so in that respect is different to gambling.
Some whole-life policies carry cash value and are an investment vehicle as well, so you can potentially make money on them surviving as well. This seems ethically-better, but most life insurance is term life that doesn't have this investment upside.