Many people would argue that the electoral college is not needed and that it is more a hindrance to democracy than a help. However, separation of powers was deemed the surest guarantee of liberty, and the Constitution builds in several inefficiencies to preserve liberty for all.
In order to persuade the original colonies to ratify the constitution, a variety of incentives were thrown into the mix. Misgivings of direct election of a president caused early colonialists to hesitate regarding the type of democracy the new country should adopt. The electoral college offers a halfway point between direct democracy in which the total of all votes cast would determine the president and one in which governors or members of Congress would vote for the president. The electoral college allows a mathematical apportionment so that citizens' votes are somewhat valuable in selecting the president.
At the Philadelphia Convention, Washington, Hamilton and Madison sought a more republican democracy. With voices on either side, the goal was to prevent the executive branch from becoming tyrannical, while also ensuring the populace of individual states did not become overly empowered. The electoral college allows small, underpopulated states to have at least three votes, no matter how small the population. This is seen as a check against larger states and ensured the Constitution would be ratified.
While often seemingly flawed in its execution, the theory behind the electoral college is that this body and the means by which electors are apportioned would prevent any area of the democratic process from becoming too powerful.