@Timjer #33029
Basically, each state gets to send a certain number of deligates to the electoral college. I believe it's one for each representative and senator the state has in congress. Each of these delegates is bound to vote for a particular candidate and how many of these electoral college votes a candidate gets in a particular state is based on the popular vote in that state.
Now, one of the big problems with this system is that each state has it's own rules for how the results of the popular election translate into electoral college votes. Some states divide the electoral votes between candidates in proportion to the number of popular votes. Some states, like my home state of California, give all their votes to whoever wins regardless of how close the results were. So, much of the actual difference in the popular vote ends up being erased when it's translated into electoral college votes. That's the main reason that it's kinda undemocratic. There are other problems too.
The original idea when the constitution was written was that each state would choose people to send to the electoral college who would represent the state, and that they would actually be the ones picking the president. I imagine a nationwide popular vote may have been difficult even back when it was still just the original 13 states. But, at some point, we did start to do that. However instead of changing the constitution to do it right, we just changed the state-by-state rules for how they chose the people in the electoral college.