For a great many decades since about the 1950s, popular culture, especially USA popular culture, has used a stock character that is commonly called nerd. There is already much written about the origin of the word itself, but until now I have not seen much about the origin of the very idea that this is a personality or character type.
Someone has tackled the topic as their Ph.D. dissertation. It is very detailed. I found it pretty informative. My only criticisms are usage of jargon such as heteronormative and Butlerian, a bit of the author's self-reference, and a complete absence of discussing features common to higher-functioning autistic/asberger people. I feel that part of the reason that the use of the character has waned or became more of a sympathetic figure is related to more awareness of them, especially as children, and the recognition of the harm of bullying.