The principal reason animating southern state opposition to direct election of the president at the time of the Constitutional Convention was slavery. To protect slavery, the southern state representatives had obtained the compromise that allocated them House seats according to population with slaves counted as three-fifths of a person.
If direct popular vote picked the president, the Three-Fifths gimmick would not have given southern states inequitable advantages in choosing the president.
Slaves of course could not vote, and the northern states had more eligible voters.
Founders from the slave states feared the outcome could be presidents unsympathetic to their "peculiar institution."
So they insisted on the electoral college system. By giving states two electors plus the number equaling the House members, the scheme extended the Three-Fifths Compromise to the process of choosing the president. It wasn't until 1860 that the unsympathetic president at last was elected.