There is no shortage of post-hoc analysis in explaining why Hillary lost, or why Trump won. But what if it’s just luck?
Because we know Trump won, we look for justifications after the fact for why he won. And had he lost, we would be looking for justifications for why he lost. Trump’s win, contrary to a common narrative, was hardly ‘inevitable’ or something that could have been foreseen. For pretty much the entire election, the polls gave Hillary a comfortable lead over Trump, both in terms of electoral count and total votes, up until in the final two weeks when Hillary’s lead suddenly began to narrow. And Hillary still got the popular vote, as further evidence of how close the election was. Had the email thing not occurred and or had some of the state results matched the polls, Hillary would have won by a small margin. Some blame her personality. She wasn’t a great candidate, but not awful either. Would Sanders have been a better candidate? Maybe… hard to know, but there’s a general consensus among the left that Hillary was a sub-optimal candidate. 
Presidential elections are won on the margins. Just being on the ballot as the ‘R’ or ‘D’ candidate is sufficient to get roughly half the votes, give or take a few percent. Once you eliminate the ‘decided’ voters and all the un-decided voters in non-swing states, you are left with maybe 100,000 people who will decide the outcome. Issac Asimov wrote a short story parodying this, in which by creating smaller and smaller subdivisions, a single person decides the outcome. So it would seem luck plays as large of a role as any sort of extraordinary badness/goodness of the candidate and or the invocation of a ‘grand narrative’ of sorts. A well-worn media narrative is that Trump’s victory is symptomatic of the ‘collective frustration’ of Middle America, but had Jeb or Cruz gotten the nomination, despite being ‘status quo’ candidates, they still would have gotten roughly the same number of votes, save for some indeterminate number voters on the margin that would have stayed home than vote for Cruz or Jeb. But by that same token, maybe Trump getting the nomination dissuaded voters who would have preferred Cruz or Jeb instead. So it kinda cancels out. Some such as Scott Adams attribute Trump’s win to special persuasion techniques, but a sample size of 1 is hard to make a generalization from. We never hear about all the times when such techniques don’t work.
The ‘median voter theorem’ explains why front-runner candidates seem to have similar moderate platforms, whereas candidates with more extreme views fare poorly, but the in the case of voter behavior it’s reversed: it’s not that politicians must pander to the ‘mean’ to get as many votes as possible, but rather that voters map their own internal biases/preferences onto one of two choices, whether the choices are good or bad, extreme or moderate.
From the Palmer Report: You’re not just imagining it: the Hillary Clinton vs Donald Trump vote totals do look rigged
In a general election matchup between one candidate who had spent the past year underperforming his poll numbers, and one candidate who had spent the year outperforming her polls numbers, the logically expected outcome is that Hillary Clinton would have won by the same amount she was ahead in the polling averages or more. Now she did win the popular vote in the general election by around one percent. But logically, based on the final polling averages and the existing pattern observed in the primaries, she should have won it by four points or more.
I don’t agree the election was rigged, but the biggest mistake was the liberal media giving Trump such absurdly low odds, which made the upset so much bigger and worse for the left. Brexit showed the failure of polling, but specifically, the fallacy of trying extrapolate odds from betting markets. All the way up until the night of the election, the bookies gave Trump just a 20% chance of winning, but that made no sense because elections are almost always decided within a 3-10% margin, and upsets are not too uncommon when the margins are so small.
The first few hours as the votes were being counted, Hillary was ahead in Florida and elsewhere, and then, inexplicably, things went to shit real fast. The same was observed with Brexit: a strong start to the favored side, and then a sudden nosedive. To have foreseen Hillary’s sudden, unexpected loss in these states would have meant having some sort insider knowledge, to be able to ascertain in real time the sentiment of these 100,000 swing voters as they were casting their ballots, that all the pollsters failed to capture.
 Its nice to see many on the ‘left’ at least trying to be more introspective in understanding why they lost, instead of like in 2000 and 2004 when there was just finger pointing and misdirected anger. Of course, there was anger on Twitter and protests after Trump’s win, but at least on Reddit things were more civil. I call it the ‘The Trump ‘Coming Together’ Moment’, which brought ‘the left’ and ‘the right’ together in online debate even if offline things were uncivil.