The business of insurance sometimes has good (profitable) years and sometimes has bad (losing) years. That’s why insurers work so hard to invest and spread their risk over multiple years. I got a dividend from State Farm during the pandemic because they had an unusually profitable year, and they re-distributed some of their profits to policyholders.
Another aspect is that insurance companies can make money on the float, and this can potentially let them be profitable while paying out more in claims than they take in (or at least netting out to paying out what they take in). That’s assuming that they can effectively invest the premiums.
Buffett successfully applied this strategy with geico.