No longer are the terms "nerd" and "geek" used as insults. We have taken them back from those who would mock us, and now wear them with pride. But those who don't remember the past are doomed to repeat it, and thus it is helpful to know what these terms originally meant, and where they came from. If only so we know that when someone calls something "adorkable," he/she is in some sense calling it "a cute penis."
The word nerd was first used in the 1950 Dr. Seuss book If I Ran the Zoo, in which a nerd was one one of the many oddly named creatures in the titular zoo. According to Ben Zimmer of Vocabulary.com, a 1951 Newsweek article mentioned it as one of the new terms being used by teenagers. It seems unlikely for teens to have latched on to a single proper noun in a Dr. Seuss book so quickly, but there is no recorded source of the word being used previously. It's possible that it was based on the 1940s slang word "nert," which referred to a stupid or crazy person. It's certainly easy to see how teens of the '50s might co-opt the adults' term for morons and use it to mean "squares" and people who didn't understand their culture.
Geek is actually an old English word meaning freak, imported via the German word "geck," which could also mean fool. Circuses in 18th century Austro-Hungary used to advertise their "geeks" as their weirdest human attractions, and the word was often used to refer specifically to those whose act consisted specifically of biting the heads off of live animals. The word had its resurgence when it was used in the popular 1941 book Nightmare Alley and its equally popular movie adaptation, to refer to such. Calling someone a person who bites the head off of live chicken's is a pretty potent way to tell someone they're weird.
Most etymologists think that dork is an alteration of the word dick, perhaps coming out of the Midwest, and thus originally meant penis, too. It was certainly used to mean a penis in the 1961 novel Valhalla, although it was spelled "dorque"; a 1964 article in American Speech confirmed its phallic meaning and spelled the word as "dork." It was also used by Charles Schmid, a serial killer known as "The Pied Piper of Tuscon," who was interviewed in the (then obviously extremely prevalent) Life magazine, in which he was quoted saying "I didn't have any clothes and I had short hair and looked like a dork. Girls wouldn't go out with me." Schmid almost certainly meant "penis" when he said "dork," but as the word caught on in pop culture it more commonly came to mean people who look uncool and/or odd.
Weirdo is obviously the noun form of the adjective weird, which is pretty commonly known to have come from the old English word "wyrd." But "wyrd" doesn't mean "weird", at least not like we mean it. "Wyrd" was a noun that meant "fate," or more specifically, Fate. When Shakespeare called the witches in MacBeth the Weird Sisters, he didn't mean they were bizarre, he meant they were the Fates, the three sisters out of Greek mythology who controlled peoples' destinies. Of course, by using it, Shakespeare helped change the word through his works' popularity — as the Fates faded from popular culture, Weird came to refer to the second biggest characteristic of the witches — that they were supernatural. Of course, supernatural is often interchangeable with unnatural, which the sisters also were, and unnatural is just a more powerful word for strange or unusual, and thus "weird" still has all of those meanings to some degree or another. The –o that turns weird into the noun weirdo is thought to come from the Middle English interjection "o," and over time become an diminutive suffix. It's the same process that turns kid into "kiddo."
The origin of the word dweeb is actually a mystery. The Oxford English Dictionary thinks it's a modern slang term derived from "dwarf" and "feeb" as in feeble, but it also says the word was coined in the '80s and other etymologists feel dweeb was a college slang word of the '60s. So... moving on.
Stupid people in America have been called goofs since the early 20th century. In 18th century English, a goff was a "foolish clown." And for centuries before that, the French were calling idiots goffe — which came whatever proto-word eventually also gave us "gaffe," meaning a blunder. Which is funny, because goof also became a verb, and to goof is basically the same thing as to commit a gaffe.
This is a term popularized in the '80s that originally meant pubic hair, as the human race never, ever has enough nicknames for our sex organs and their surrounding areas. Its use as an insult came quickly enough, popularized by its use in 1986's Bill & Ted's Excellent Adventure, which is awesome because the Oxford English Dictionary has an entry for it, which includes the Bill & Ted's reference. From there's it's an easy step to get to its linguistic pal the "dickwad." And of course "dillweed" is to dickweed as "fudge" is to fuck — the socially acceptable variant. Which is almost certainly why Beavis & Buthhead used it so frequently on the somewhat more conservative MTV of the ''90s..
While egghead was used to refer to bald people early in the 20th century (not because their heads were egg-shaped, obviously, but because they were both smooth), poet Carl Sandburg actually popularized its meaning of "intellectual" back when he was a Chicago newspaper journalist, using it in a 1918 article implying that "eggheads" were people full of knowledge but otherwise vapid (hence the metaphor having a large skull, but one that was also extremely fragile). Egghead was certainly a negative term when Richard Nixon used it to describe his boss Dwight Eisenhower's political opponent Adalai Stevenson in 1952.
This uncommon name became even more uncommon after it became a synonym for nerd, and its all thanks to Felix the Cat. When the 1959 Felix cartoon debuted, it introduced a great many new characters including Poindexter, the nerdy nephew of the Professor, who dressed in a lab coat, wore thick glasses, was super-smart and socially awkard. The character was such the perfect representation of what a nerd meant at that time, the character's name enter pop culture, and the term has remained even as the character has been almost completely forgotten.
Image from Knights of Badassdom.