2012 is instructive here. Republicans lost, which amplified a massive internal debate going on at the time: Ron Paul
got screwed over, the libertarians generally felt kicked out of the party, the New Right conservative ideology was in tatters. The grassroots Tea Party delivered success in 2010, and they blamed "the elites" for the loss in 2012. (Ask a Republican in DC about the "cocktail parties" they go to, and watch them roll their eyes in exasperation.)
In fact the grassroots vs elites friction had been going on since the 2nd Bush term. The Democrats' red state/blue state narrative sunk into the GOP as well, and as people in red states thought of themselves as living in red states, they started to blame every political setback on RINOs living in blue states, including the very blue Washington DC. People remember Ann Coulter's famous
prediction for Trump's win on Bill Maher's show; they forget she had been screeching against The Elites for 5+ years at that point.
So Trump, a 1960s-era Democrat populist, comes in and blows away the multiple factions in the GOP: New Right, Tea Party, libertarians, compassionate conservatives, moderate governors, New England RINOs, southern Evangelicals. He co-opted the base of some of them and just ridiculed the others into oblivion. The rest is history, as they say, but the point is that groundwork was laid during the previous election cycle.