This Wikipedia article, though brief and lacking much detail, describes the relationships between the various terms.
Basically, "idiot" has an IQ of 25 or below, "imbecile" has an IQ of 26-50, and "moron" has an IQ of 51-70.
Another reference describes the "mental retardation" scale that replaced idiot/imbecile/moron:
IQ score ranges (from DSM-IV, issued 1994):
Mild mental retardation: IQ 50-55 to 70; children require mild support; formally called "Educable Mentally Retarded".
Moderate retardation: IQ 35-40 to 50-55; children require moderate supervision and assistance; formally called "Trainable Mentally Retarded".
Severe mental retardation: IQ 20-25 to 35-40; can be taught basic life skills and simple tasks with supervision.
Profound mental retardation: IQ below 20-25; usually caused by a neurological condition; require constant care.
(When I had conversations with workers at the local mental hospital in 1974 they were using the terms "Educable Mentally Retarded" and "Trainable Mentally Retarded", rather than "Mild" and "Moderate".)
It's hard to find precise info on when the various changes occurred, save that (in the US) "Rosa's Law" was finally passed and signed in 2010, changing "mental retardation" to "intellectual disability" in US law.
As for the origin of the "offensive" sense of the above terms, people are people. If "idiot" or "retarded" is used as a technical description of a condition, and that condition implies something "bad" about the person with the condition, people will use the term as an insult. No one "invents" this usage, it just happens. The fact that "intellectually disabled", the latest term, is not (to my knowledge) already a popular insult is simply because it's too long and complicated to say (especially compared to "idiot" or "retard").