Many of these types of words had functional use at one time. If you check Ellis Island immigration records you’ll see people classified as “idiots”, “imbeciles”, “morons”, and other similar terms based on an aptitude test administrated. Those 3 terms describe different levels of perceived intelligence.
Of course as they often do, these terms of classification became derogatory after people used them as an insult.