In some stories, a person who is insane or at least eccentric may at the same time be one of the kindest and most generous characters. There may be various reasons for this: for example, such characters may preserve childlike innocence lost by "normal" people, or their madness (especially if it is of a religious character) may inspire them to do things that are considered "irrational" or "meaningless", like assisting a seemingly desperate cause or sacrificing oneself for the Greater Good. This trope is Older Than Print: in medieval times, it was a common belief that eccentrics and weirdos were "touched by God", and many saints and blessed ones behaved in a quirky manner.
The character could be freaky or do nonsensical things, but that doesn't mean they are harmful to society, or evil in nature and morality. They are pleasant and do kind acts here and there despite what their otherness or freakiness may suggest. May or may not be a Lovable Nerd.