Only five presidents have been elected even though they lost popular vote. John Quincy Adams in 1824, Rutherford Hayes in 1876, Benjamin Harrison in 1888, George W. Bush in 2000, and yes...Donald Trump this November.
As prescribed in the U.S. Constitution, American presidents are elected not directly by the people, but by the people's electors. The Electoral College was created by the framers of the U.S. Constitution as an alternative to electing the president by popular vote or by Congress