The electoral college system for choosing the President was based upon the protection of slavery and a distrust of democracy. That system has allowed the loser of the popular vote to win the Presidency in five of our 56 Presidential elections. Such a system would be illegal in any state or local election. But it is contained in the Constitution. Can a section of the Constitution itself be unconstitutional? The answer is yes.
We are all aware by now that we do not vote directly for a candidate in a Presidential election. We vote for electors who will (presumably) vote for the candidate who won the popular vote in the state, when the college meets after the election. Under Article II, Sect. 2 of the Constitution (later modified by the Twelfth Amendment), the number of electors is determined by combining the number of members of the House of Representatives in each state and its two Senators.