Risk analysis is just an implementation detail that aids price discovery in a competitive market. If an insurance provider can identify customers with lower risk than the consensus, they can offer lower premiums and attract that business. If they identify customers with higher risk, they can charge higher premiums and push that unprofitable business to a competitor.
Supposing this price discovery were perfect, customers who make a claim would have already paid premiums equal to the claim, and customers who never make a claim would pay nothing (plus fees in each case). This aspect of insurance obviously serves no core purpose. The purposeless of it is just hidden in the noise of uncertainty, and we see pricing differences emerge out of the uncertainty.
The actual purpose is to blunt the effect of catastrophic losses by spreading a smaller burden across a larger population. One caveat is that insurance can sometimes have the effect of "rewarding" risky behavior and "punishing" cautious behavior. Now, it's interesting that price differences can sometimes balance that by reversing the punishment/reward incentives, but only if prices are based on risk factors that the customer can actually control.