How does insurance company benefit from life insurance?

As with any kind of insurance, the insurance company benefits by distributing risk according to statistical models, finding out how much it would cost them to pay out claims against all their insured clients, and then charging their clients more than their analysts tell them they will have to pay.
With life insurance you pay an annual premium that could be fixed, or could go up significantly the older, more sickly, or more likely to die you become (depending on your type of coverage).

So if you are twenty years old and take out a 20 year term life insurance policy, the insurance company knows what the exact % chance is that a person who more or less fits your description will die in the next 20 years. They factor that out across all their customers, and then they charge their customers more than they expect to pay out.

Insurance benefits unlucky people and insurance companies. Everyone else loses.