The transaction comes as insurers and others are looking for ways to control costs and stave off future challenges from companies like Amazon.