Elizabeth Drew, a longtime journalist on political matters, provides a comprehensive discussion of how Trump prevailed (NY Review of Books—might be paywalled). We should keep in mind that this election was very close. A very minor change in several factors could have easily yielded a landslide victory for Clinton.
That said, I was a Bernie Sanders supporter, though I felt it morally imperative to prevent a Trump win in the general. Yet, the criticisms leveled by Sanders against Clinton (and her damnable husband) still ring true. Moreover, we have to wonder if a president Hillary could have accomplished much of anything against an ever more intransigent Congress. Surely she would not have gotten any Supreme Court nominees confirmed.
Now, of course, Trump is poised to do so much damage. It could be huge. In a very bad way.