Why did the delegates who wrote the American Constitution select the indirect elections of the president by the electoral college?
There are a couple basic reasons for this. First of all, the founders of our country didn't have all that much faith in the "average" person's ability to make good decisions; in fact, their attitude would seem more aristocratic than democratic to us. As Hamilton wrote in the Federalist Papers: "It was equally desirable, that the immediate election should be made 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." They clearly though that governance should be in the hands of those they decided were "capable," not in the hands of all of us, the "mob."
The second reason relates to the fear by the small states that they would be so overwhelmed, that their "voice" would not be heard. (It helps to remember that there were no political parties when the college was formulated, and that communication was slow and inefficient and there was a fear that a candidate in a very populated region could take over the election.) The college guaranteed them a voice in the election. The concerns of the small states had a great deal to do with the formulation of the constitution. You might want to read a popular history like "Miracle at Philadelphia" for a fuller understanding of this important "conflict."
The Electoral College was set up as a means to establish, as you said, an indirect method of presidential elections. The rationale for this, while not simple, is fairly straight forward.
1. At the time of the founding of the nation, there was limited eligibility for voting: being white and a land owner were the two main necessary requirements that prevented well over half of the nation from voting.
2. At the time of the founding of the nation, the literacy rate for the nation was not near the level of our modern rates today. Because of this fact there was some fear that a direct vote could be manipulated by emotional appeals to the majority that might be informed enough to avoid being swayed.
3. At the time of the founding of the nation, there was some fear of rob rule on the part of the public. The leaders of the Revolution had spent a great deal of time, money, personal sacrifice, and reputation to free the nation from England and they wanted to have more say in the early founding of the nation.
By setting up an indirect selection process of delegates for the Presidential election and as the selection of US senators, these men felt that the nation would be able to "grow up" under limited mob rule mentality.