The Electoral College was created largely because of the fact that the people who wrote the Constitution were very wary of the idea of democracy. They did not believe that the people as a whole had the knowledge that they needed to be worthy to elect their leaders.
At the time of the writing of the Constitution, many of the Framers had a deep distrust of democracy. No country to that point had ever been truly democratic. Democracy was associated in their minds with the idea of mob rule. They believed that the mass of the citizenry would be too ignorant to really know how to vote. Such people might simply follow a demagogue who promised them things that they wanted, even if those things were bad for the country as a whole. For this reason, the Framers did not want a system in which the people directly elected much of the government. They created the Electoral College and they insulated the Senate and the Supreme Court from direct election as well.
Thus, the Electoral College was created because the Framers did not trust the people to elect their own leaders.