Nearly 30 years ago, a mathematician and a psychologist teamed up to explore one of life’s enduring mysteries: What makes some marriages happy and some miserable?

The psychologist, John Gottman, wanted to craft a tool to help him better counsel troubled couples. The mathematician, James Murray, specialized in modeling biological processes.

It...