When you read about Hans' life you get the impression he was a bit... odd
He attended a school for children when he was 22. He would start acting scenes of his plays at social events, unprompted, often interrupting whatever was going on. Charles Dickens was nice to him once and Hans took that as an invitation to spend over a month in his house, never realizing he was making Charles and his family very uncomfortable, never understanding they didn't like him back. He was open about his homosexuality but in a way that suggests he didn't actually know it was a taboo in his culture, like sending letters to men he was not close with about how "they made him feel like a woman," often making those men very uncomfortable...
It just doesn't sound real, it sounds like a little kid who doesn't understand how society works doing whatever he wants, except this was a grown man
Some may argue he was just "eccentric" but he doesn't seem eccentric to me, rather it sounds like he may have had a mental disability. That would explain why he was often so naive and clueless, and it would make his accomplishments all the more remarkable
Because I don't want to make it sound like I don't admire Hans. He wrote some of the most beautiful fairy tales in history and he rightfully deserves the fame he has to this day. If he was disabled in any way that just means his work is even more special than we thought
H.C. Andersen tended a kids’ school at age 22 because he was brought up in poverty, and therefor only had access to very basic schooling, like reading, writing and math. When he moved to Copenhagen at age 14, he quickly made a name for himself on the stage because of his excellent soprano voice, but due to puberty, his voice changed and he soon found himself unable to get anymore acting jobs. When this happened, a colleague at the Royal Danish Theatre, suggested H.C. Andersen that he should pursue poetry. The director of the Royal Danish Theatre, Jonas Collins, helped sending H.C. Andersen to grammar school, and later latin school. That’s why he was so much older than his fellow students. These years have later been described, by many historians, friends and H.C. Andersen himself, as the darkest years of his life.
The following years and antics could be argued as being down to H.C. Andersen being autistic, but it is difficult, as the the diagnose would have to be in retrospect.
In the 2005 book The Genesis of Artistic Creativity: Asperger's Syndrome and the Arts, Irish professor of child and adolescent psychiatry, Michael Fitzgerald, agues that H.C. Andersen might have had Asperger's Syndrome, although in an interview with Danish newspaper, Berlingske, later the same year, Michael Fitzgerald is quoted saying "I am 100% certain he [H.C. Andersen] had Asperger's Syndrome". The English psychologist, Anthony John Attwood (Tony Attwood) responded to these claims, stating that while H.C. Andersen’s antics displayed behavioural patterns similar to autistic people, you should never diagnose someone based on what other people say.
In H.C. Andersen’s autobiographies, the way he describes himself and his life, could work as a good first-hand source, but professor of Scandinavian studies, Walton Glyn Jones, argues that when H.C. Andersen wrote his autobiographies, he was taken over by the myth he had created about himself, and therefor we cannot use these as correct sources. This statement is backed up by Danish historian and litterature researcher, Johan de Mylius, in his book H.C. Andersen, Life and Work, where he describes H.C. Andersen’s upbringing in poverty and hardship, completely in contrast to the describtions in H.C. Andersen’s autobiographies, where his upbringing is described as rich and wonderful, fairy-tale like.
This makes it extremely difficult to provide a final answer to whether H.C. Andersen had any mental illness, as our best sources are two leading experts who disagree.
For further reading, I highly recommend the book The Inner Line of H.C. Andersen’s Fairy-tales: A Psychological Study by Eigil Nyborg (ISBN: 8702035197)