It’s that time again folks: time to relearn everything you’ve forgotten about the electoral college in the past four years.
The Background

The electoral college was invented in the 18th century because no one had a telephone. Proponents of the system will tell you it was made to ensure the bigger states wouldn’t just decide the presidency regardless of what the smaller states think, but that’s not true. Really, the US just needed a way to hold a nationwide vote while not being able to know results from all states at the same time.
In the absence of CNN, the founders decided that each state would vote for electors- people to go to Washington to vote for the president on their behalf.
How to Win

Each state has a number of electoral college votes equal to their number of Representatives in the House (roughly proportional to population) plus their number of senators (two per state). This means that regardless of population (or lack thereof), every state is guaranteed three electoral votes. Currently there are 538 (like the website) votes in the electoral college, meaning you need 270 to win (also like the website).
In 48 states and the District of Columbia, it’s winner takes all. Maine and Nebraska do their own thing, in the first of a number of examples of the presidential election varying state by state. In each of these states, a number of electors are decided based on the statewide vote and assigned as winner takes all. However they also have an electoral vote for each of their congressional districts (three in Nebraska and two in Maine), who are assigned based on who wins the vote in that district.
The winner takes all system, combined with the disproportionate distribution of electoral votes, means that a candidate can win the electoral college without winning the nationwide popular vote. A candidate may win by a huge margin in the most popular states, but if their opponent wins by a sliver in enough small states, the opponent wins. Theoretically, you could win the vote of every one of New York’s 19 million residents, and their 29 electoral college votes. However you could also win 29 electoral college votes by winning a simple majority (a combined 4.7 million votes) in each of Wyoming (3), Alaska (3), North Dakota (3), South Dakota (3), Montana (3), Idaho (4), West Virginia (5), and Nebraska (5). Obviously no candidate would ever win every voter in New York, and most margins of victory are larger than a single vote. But a version of this scenario happens in nearly every election with more states, and has resulted in the winner of the popular vote losing the electoral college five times- most recently in 2016, when Trump lost by 3 million votes.
Because of this, every presidential race tends to boil down to a handful of swing states. Most states are solidly Democratic or Republican, so there’s no point attempting to grow a margin in any of those when you could campaign in a state where the result is likely to be close instead. For example, although California has the most electoral votes of any state (55), there’s no point campaigning there when it will nearly always go Democratic. Instead,a candidate is better off spending time and money in a Wisconsin or a Florida or a Nevada, where the result is more likely to be close.
Faithless Electors

33 states and DC have laws which force their electors to vote according to the result in that state. In the other seventeen states, electors can basically vote for whoever they want, although they rarely do. Electors who do vote against their state’s wishes are known as faithless electors.
2016 had seven faithless electors, which was more than any election in history, but not enough to make any difference to anything.
I’m sure John Kasich was happy with his single electoral college vote though.
What Happens If No One Wins?

While extremely unlikely, it is possible under the current system that there could be a tie, or that a third party candidate prevents anyone from winning a majority of the electoral college. In that case, the House of Representatives would elect the president, with each state delegation having one vote. The Senate would pick the vice president, with each senator getting one vote.
This is one of those hypothetical scenarios like a contested primary convention which the media salivates over, and that happens all the time in tv shows, but is realistically wildly improbable.
How to Fix This Mess

The focus on winning a handful of near-random states instead of actually trying to win the overall population would be bad enough, but the (seemingly increasing) frequency with which the electoral college produces a winner who did not win the national popular vote is anti-democratic to its core. However abolishing the electoral college is virtually impossible. It would require a constitutional amendment, which takes two thirds of state legislatures to approve. This is hard to do at the best of times, but would certainly be rejected by the states who would lose out on their current outsized influence.
A number of states have come together with a plan to fix the problem of the electoral college that wouldn’t require outright abolition. The National Popular Vote Interstate Compact is an agreement whereby member states would award their electoral college votes to the winner of the nationwide popular vote, regardless of who won their state. Notably, the agreement doesn’t come into effect until enough states representing a majority of the electoral college have joined.
To date, the NPVIC has been adopted in 15 states and DC, representing 196 electoral votes in total. These are all blue states so far, but it is at least a start.
Worth a look:
CGP Grey has a good series of videos about the electoral college, its flaws, and the NPVIC: