You could point to a number of factors leaving the GOP in the sorry state it's in.
Reagan's use of abortion and other religious topics as wedge issues has made the party not only obsess over maintaining conservative Christianity, but doing so in a hypocritical way (they love inflicting suffering and death, just on certain people).
I'm still convinced 9/11 gave conservatives the notion that Republicans had a divine right to rule forever, as they were surely the only ones who could fight terrorism. Goodness knows the "Obama's a secret Muslim terrorist" freakout in 2008 was fueled in part by a mindset like that.
Tea Party conservatives' mix of knee-jerk "all government bad" libertarianism and populism certainly didn't help.
The gerrymandering and disenfranchisement of the past decade or so is a problem, too. It not only gives Republicans little incentive to change, it creates a vicious cycle where anything and everything they do to hold on to power is justified. If you've already cheated to stay in office, what's a little more cheating?
I'm sure the fear of a demographic shift drives things. On top of racism for some supporters and politicians, there's also the reality that the shift could cost Republicans in the long run as they continue to alienate most everyone who isn't a white, straight Christian. It's like a college frat holding one last, extra-long party knowing it might never have that chance again (in this case, that Republicans may lose every federal election after a certain point unless they adapt to reality).
And of course, Trump was the nail in the coffin. Truth no longer matters to devoted supporters. Open, flagrant corruption is acceptable as long as it's your corruption. Science and the free press are enemies; compassion is evil. And if you dare disagree with Dear Leader Trump, you're a pariah even if you're otherwise fiercely loyal to the party (see what's happening in Georgia as an example).