As to why they created the system they did, when they were writing the Constitution, in 1787, they were assuming there would be no parties. This was very utopian thinking, because there had been parties in Britain, and it was obvious there were factions developing in America. So if you have no parties, each elector casts two votes for the two guys he thinks are best, and you just get two good candidates. This is especially true if there is no popular vote. This system was doomed to failure, but it worked for both of Washington's elections. All the electors cast one vote for Washington, and then they debated who should be VP, and they settled on Adams. (This system works better when there's no popular vote. Only half the states had a popular vote in 1788 and 1792, so the electors were free to discuss among themselves who they wanted.)
But the two party system coalesced around Jefferson's Republicans and Hamilton's Federalists during Washington's presidency. The Federalists nominated Adams rather than Hamilton because Hamilton had a sex scandal and Adams had seniority. (Adams was also much more of a moderate and had some of Washington's non-partisan spirit). The Federalists won that election, but they didn't have a "running mate," so their second vote was scattered. Adams became President and Jefferson became VP. So in 1800, the Jeffersonian 'Republicans created the whole running mate idea. They won a majority of the electoral college, and their electors vote for Jefferson and Burr. This ended up resulting in a tie between Burr and Jefferson. So that election went to the House of Representatives and Aaron Burr tried to get the House to vote for him. Hamilton hated Burr more than he hated Jefferson (and he hated both), so he had the Federalist House members vote for Jefferson. The election made them realize that as long as there was a party system, elections would be decided by the House rather than the Electoral College, and they created the 12th Amendment.
That's essentially right, but there are a few minor points I would quibble with.
First, it's not quite true that the Jeffersonian Republicans invented the concept of a running mate in 1800. The Federalists did have the idea of a running mate in 1796, and Adams's intended vice-president was Thomas Pinckney. The idea was that all the Federalist electors would cast one vote for Adams, but that one or two would not
cast their second vote for Pinckney, thus ensuring that he had ever so slightly fewer votes than Adams, so that Adams would be president and Pinckney vice-president. But two things complicated this. First, no clear plan was worked out as to which electors would withhold their votes for Pinckney - that was left to be worked out on the day the electoral college actually met, which would seem to invite confusion. Second, there was a scheme by some Alexander Hamilton and a few anti-Adams southern Federalists to get Pinckney elected president instead Adams, by casting one ballot for Pinckney but the other for Jefferson. Word of this scheme got out, and it made a lot of pro-Adams Federalists reluctant to vote for Pinckney, for fear that the scheme would work. So, some voted for Pinckney but not Adams and others (a greater number, as it turned out) voted for Adams but not Pinckney. It wouldn't have mattered if the election hadn't been close, but it was very close, and Jefferson managed to squeeze into the margin between Adams and Pinckney.
In 1800, again, both candidates had running mates. Adams's running mate was actually Charles Cotesworth Pinckney, the brother of his running mate from 1796. Jefferson's was Aaron Burr. Again, the idea seems to have been that all but one of the party's electors would vote for the running mate. Both parties seem to have learned their lesson, and there was no potentially self-injuring intrigue this time. The Federalists electors voted exactly as planned: all of them voted for Adams and Pinckney except for one, who voted for Adams and John Jay. The Republicans planned to do the same thing, but failed at the logistics of it; whoever was supposed to withhold their vote for Burr apparently didn't get the memo, and they all voted Jefferson-Burr.
It's also not really true, despite what one often hears, that after the tied vote Aaron Burr somehow connived to steal the election from Jefferson. He actually made no public statement on the subject of the contingent election in the House and he didn't try to influence it in either direction. In fact, he wrote to Jefferson that he still fully supported him for the presidency and that if the House selected him, he would step aside for Jefferson. Now, one could argue that he should have made a public statement to this effect, and certainly by modern standards his failure to do so would be judged quite harshly. But recall that at the time it was considered unseemly for candidates to participate directly in the campaigns and elections at all, so the fact that he made no such announcement is hardly surprising.
Moreover, Burr presumably fully expected the Republican delegations in Congress to vote for Jefferson - which, in fact, they did. It was actually the Federalists who made an attempt to embarass Jefferson by electing Burr instead of him. There were 16 state delegations, so Jefferson needed nine to win. Seven of those delegations were controlled by Republicans, one was evenly split, and eight were controlled by Federalists, so it was a close thing, and for 35 ballots the vote was 8 to 6 in favour of Jefferson, with two state delegations split. In the end, Alexander Hamilton, who hated Burr for personal reasons, convinced some of the congressional Federalists to give it up.
Sorry for the long-winded nitpicking, but this is one of the historical periods I'm rather geeky about. Also, I think Burr is one of the more unfairly maligned historical figures.