I think it's a combination of factors:
1) he wasn't Hilary Clinton. Other than people not wanting another Clinton, they also didn't want a woman
2) people were getting annoyed with politicians screwing them over. He didn't go through the full political system and he claimed that he wasn't one of the politically elite. Which made it even funnier when he did what every other President did before him
3) Nationalism. America is built on America being the best at everything. A candidate that claims he will make America the best, and holds strong anti-immigration policies, that's going to be a good option for Americans
4) online Disinformation campaigns run by Russian hackers and far right groups worked well. People actually believe shit they read online so when they're told that Hilary is an evil pedo, they believe it
It was the perfect storm. A time when America is struggling, the Internet is primed for misinformation, and the country hasn't reached a point where they fully respect women and minorities.
That's the kind of perfect setup for someone like Trump to come in. Fortunately he was just an idiot. If he was anything like other leaders that rose up in similar ways, it could have been a lot worse.