In Ancient Greek, hoi polloi means ‘the many’, or ‘the majority’. In English, it means the masses or common people in a derogatory sense.
“When red-headed people are above a certain social grade their hair is auburn.” – Mark Twain
In the Ancient World however, it was not a derogatory term. It was used by Thucydides in his History of the Peloponnesian War. The term was used to praise the Athenian democracy, contrasting it with hoi oligoi, meaning ‘the few’; from which we get the word oligarchy.
Hoi polloi is sometimes used incorrectly to mean ‘upper class’, i.e. the exact opposite of its normal meaning. It seems likely that the confusion arose by association with the similar-sounding but otherwise unrelated word hoity-toity.