They could have won against the unpopular Biden/Harris with practically any other candidate. Nikki Haley polled well against all possible Democrats.
The party was already done with Trump in February 2021, but then they explicitly decided that they prefer one more try with an old man who doesn’t spare much thought to actual policies but does brag about sexual assault, tried to orchestrate a coup last time he lost an election, etc. etc.
It’s not inflation or Biden’s unpopularity or some other external factor. Lots of Americans really want what Trump is selling.