Donald Trump's victory in the 2024 general election surprised many experts, largely because his rhetoric seemed to alienate many segments of the population, including women, immigrants, Latinos, minorities and those concerned about civil rights. On the bright side, there actually will be a peaceful transition of power, and there also isn't any political heir waiting in the wings who has Trump's innate ability to generate that same level of cultish devotion, which is quite rare.
The reason Trump won is overwhelmingly simple: there was a cost of living crisis in the United States, as there was around the world post-covid, and the Biden Administration failed to meaningfully address and try to solve the issue. So swing voters did what they always do when the economy is perceived as not doing well: they voted against the incumbent party in hopes that things would change under the other party. It was the same reason Clinton won post-recession in 1992, Obama won post-housing crisis-driven recession in 2008, and so on. It's a matter of being in the right place at the right time. Looking forward, if mass deportation ends up tanking the economy, the Democrats' fortunes might improve in 2028.