Yes, the structure is similar.
Specifically, insurance is like gambling at a casino rather than a friendly poker game. The casino knows that some fraction of people will win. It sets the prizes accordingly so that in the long run, the casino will pay out a little bit less than it takes in. For the individual players gambling is a matter of chance, but there are so many players that there's no risk for the casino.
An insurance company likewise knows that it will have to pay out to some fraction of its customers, so it sets its premiums in order to make a little bit of profit. Neither industry can set their profits too high, or customers will go somewhere else.
Health insurance is somewhat different, in that it also has to cover predictable costs like regular checkups and pre-existing conditions. That's why the system in the USA is such a mess right now: things that should probably be rights paid for by the government are being lumped in with gambling.