Insurance, classically understood, is risk sharing, not cost sharing. In other words taking it from a "not everyone will use this service" risk sharing model to "everyone will use this at some point" cost sharing model is what causes the problem of hidden pricing.
You can have it both ways (risk sharing and visible prices) because most healthcare costs aren't unforeseen. In other words, the number of accidents where the hospital needs to be relatively sure insurance is involved pales in comparison to the cost of routine visits/care which could be paid for out of pocket and prices would then be visible allowing for competition.