In February 2014, a group of conservative political donors gathered at New York’s Pierre Hotel to strategize about the coming presidential contest.

Robert Mercer, a computer programmer and hedge-fund manager who distrusted the political establishment and loathed Bill and Hillary Clinton, issued a warning: Data he had seen indicated mainstream Republicans such as Jeb Bush and Marco Rubio would have difficulty winning the White House in 2016, according to one of the attendees. He said only a true outsider with a sense of voters’...