People are saying that the reason we elected Trump is that the electorate indulged in a hidden racism. Though this seems to have been a component, I don’t think that this is the main case. Here I present my hypothesis of why we elected Trump.
The decision (I think) was made largely on economic differences between Clinton and Trump. Clinton supported NAFTA (instituted by her husband) and TPP (until Sanders criticized her on it, at which point she flopped). She also criticized Trump for saying he would build a wall (after she voted to build a wall in the Senate). NAFTA, exactly as Perot predicted, did indeed remove jobs from the US. The car manufacturing of Detroit and Flint are gone, the steel production is gone, our textile manufacturing is gone, and there was never a real electronic manufacturing industry here. We can’t simultaneously impose employment restrictions (workman’s comp insurance, minimum wage, health insurance, workplace safety) AND open the borders to allow corporations to hire in places where those restrictions don’t exist. That kills American jobs. In particular, it kills jobs in exactly the places that voted for Trump (the midwest).
Trump, on the other hand, criticized NAFTA and TPP. He said he would secure our border, and impose tariffs on companies building products overseas. Those actions would directly increase American jobs, especially in the regions that voted for him. (It remains to be seen, of course, if he will actually do these things.) What did Clinton say she would do? Free Pre-K for all children, reduced cost of a college education, and more Obamacare. When offered charity or a shot at earning a living, our electorate chose the latter IN SPITE of the racism, misogyny, and bigotry.
Other issues that played a role:
- Trump said America was becoming a third world country. Clinton said America is a wonderful place. But it’s true that our infrastructure is old and wasting (roads, airports, bridges). Flint doesn’t even have water it can drink (lead in the water), and we now know this problem also exists in Portland , Florida , and several other places.
- The unemployment figure is horribly gamed  and varies widely across the country.
- The price of Obamacare is going up and the options are getting reduced .
- Clinton, as secretary of state, perpetrated America’s eternal war across the globe (Libya, Iraq, Yemen, Syria). Trump, on the other hand, has an anti-war policy  which feeds directly into increased prosperity for the US.
 “John Oliver – Last Week Tonight: Infrastructure” https://www.youtube.com/watch?v=Wpzvaqypav8