Once again, we have a popular vote loser taking the White House, and once again we have criticism and fights over the existence of the Electoral College. The reason for why we have the Electoral College is poorly understood – supporters usually make the argument that it was designed to ensure that smaller states weren't swamped in a presidential vote.
A look at the contemporary discussions in the 1780s and James Madison's notes on the debate in the Constitutional Convention shows that this is incorrect – the Electoral College was actually created to both separate the powers and combat corruption from both foreign and domestic sources.
It is important to look at how the Convention arrived at an Electoral College. With the exception of the Pennsylvania delegates, popular election of the president didn't have much support. Instead, the first plan presented – the Virginia or Randolph Plan – proposed that the Executive be elected by the new legislature, which would eventually be called Congress.
This would have made perfect sense to the conventioneers. At the time, in eight of the 13 states, Governors were selected by the state legislature, not the voters, and in two others states, the legislature made the choice if no candidate received an absolute majority.
Early on, the Conventioneers adopted this view – on June 2, the convention voted to have the legislature elect the president. Pennsylvania Delegate and future Supreme Court Justice James Wilson, the leading proponent of the popular election of the president, first proposed a prototype of the Electoral College, which was rejected 8-2.
On June 9, they rejected an idea that the state Governors would choose the president, and Alexander Hamilton proposal for an Electoral College-type plan was rejected on June 18. On July 17, they returned to the issue and rejected both a popular vote method and a quasi-Electoral College approach, and reapproved the idea that the legislature would choose the president.
They reversed this action on July 19 and adopted a nascent Electoral College plan, but then reversed that on July 24. An Electoral College plan was defeated again on August 24. It was at only at the very end of the Convention on September 4-8, that a Committee of 11 put the Electoral College fully into play and the idea was adopted for good.
A look at Madison's notes shows that the Convention kept considering an Electoral College for specific reasons, one that was not focused on helping small states or ensuring that every part of the country was heard from – that was what the Senate was for.