They started out insuring farms against calamities. If a farm burned down, it was a proper disaster: for the farmer, for everyone who worked there, and for the surrounding area relying on the farm for food. So the farmers got together and started the insurance company on the premise that it's better for all of them, together, to take a continuous economic hit than to live under a constant existential threat, individually.
It's not only that they continuously pay to be insured before the disaster happens, it's also the fact that if they are helped during a disaster, they can continue to contribute afterwards, for as long as the farm exists. Whereas, if disaster hits and they are permanently gone, that's a permanent end to their contributions, as well as a hit to the community in countless other ways.
This particular insurance company was non-profit from the start, and still is.
For device insurance, I agree that you pay mostly for peace of mind. But like parent, I'm not sure I'm willing to write off all insurance as a racket.