The reason that the Constitution calls for this extra layer, rather than just providing for the direct election of the president, is that most of the nation’s founders were actually rather afraid of democracy. James Madison worried about what he called “factions,” which he defined as groups of citizens who have a common interest in some proposal that would either violate the rights of other citizens or would harm the nation as a whole. Madison’s fear — which Alexis de Tocqueville later dubbed “the tyranny of the majority” — was that a faction could grow to encompass more than 50% of the population, at which point it could“sacrifice to its ruling passion or interest both the public good and the rights of other citizens.” Madison has a solution for tyranny of the majority: “A republic, by which I mean a government in which the scheme of representation takes place, opens a different prospect, and promises the cure for which we are seeking.”
As Alexander Hamilton writes in “The Federalist Papers,” the Constitution is designed to ensure “that the office of President will never fall to the lot of any man who is not in an eminent degree endowed with the requisite qualifications.” The point of the Electoral College is to preserve “the sense of the people,” while at the same time ensuring that a president is chosen “by men most capable of analyzing the qualities adapted to the station, and acting under circumstances favorable to deliberation, and to a judicious combination of all the reasons and inducements which were proper to govern their choice.”
http://www.usatoday.com/story/news/politics/onpolitics/2016/11/07/why-do-we-have-an-electoral-college/93440438/