In some circles, talking to invisible beings would be considered a form of mental illness. Admittedly I tend to frown on such behavior but I try not to judge that lifestyle and instead would happily allow them legal freedom to do so.
Homosexuality used to be listed as a mental illness but has since been removed. (Since there really is no inherent problem with it; just prejudice). Gender Identity Disorder / Gender Dysphoria is currently listed as a mental illness, but the treatment for that generally includes medical treatment and hormones to correct the problem and focuses on the body rather than the mind after research has indicated that this is the way to fix it. It's debatable what type of problem it should be listed as, since medical and mental health professionals find that changing gender identity doesn't work and changing the body does work so it's more like a medical issue. Overall those that transition to the other sex are generally treated by professionals as having a medical problem rather than a psychological problem despite the fact that Gender Dysphoria is in the DSM.
It would probably be a much easier problem for them to work through if there was far less discrimination. If their family, friends, and employers were familiar with the medical research, and happily and lovingly helped them work through the biological changes while providing emotional support and acceptance (like we do for just about any other physiological challenge), things wouldn't have to be so difficult. Instead, a subset of them often face family rejection, friend rejection, get fired, get called things like "it" or "tranny" or are generally disrespected. One in a several hundred people is inter-sexed in some way or transgendered, so as a society we really need to be more informed and educated about gender identity overall.
One of the reasons I'm fairly familiar with transgendered topics (besides personally knowing more than one person that transitioned) is that as a former resident assistant at a university, I was part of a building that was specifically meant for LGBT individuals (they could of course live anywhere on campus but if they specifically wanted a place that was potentially friendlier to them the LGBT area was an option). I was assigned there as a resident assistant randomly. Some of the areas that students could live in had specific purposes: like all engineers, or all people on sports teams, or all people who identify as LGBT in some way, etc.
The LGBT area had individual bathrooms that were not gender specific in order to help transgendered individuals feel comfortable regardless of what stage of transition they were in, since they didn't have to make any choices about which gendered restroom to use. As employees there, we had to read legitimate research on both homosexuality and transgenderism so that we weren't bad at our jobs. I ended up reading extra professional/medical info on transgenderism on my own time because the philosophical aspects of gender identity were interesting to me and it was a bit more complicated to deeply understand overall.
What helped me understand it was realizing that there is a separation between personality and gender identity. I understood early on that sexual orientation and gender identity were distinct, but it took a bit of extra time for me to understand that personality traits and gender identity were distinct.
For example, there could be an extremely 'feminine' gay man. The second you meet him, you naturally assume he must be gay by his voice tone, movements, appearance, etc. And yet he may not have gender dysphoria at all; he could be entirely happy as a male. Similarly, you could have the most 'masculine' woman. You don't view her as very feminine. But she could be very happy as a woman.
On the other hand, you could have a genetic male that has a female gender identity despite not being overwhelmingly feminine. He might even be less publicly 'feminine' than the previously described gay man, and yet he has gender dysphoria. He specifically feels he is female, is extremely depressed in a male body which therapy does not address, and a transition towards a female body solves her problem by altering the body to be feminine to match her gender. Likewise, there are women that really feel that they are males and cannot exist happily in a female body. So they transition to being males. There are various studies that suggest that certain areas of the brain, like the stria terminalis, are different for transgendered people in the sense that they more closely resemble the target gender rather than their genetic sex.
Overall, the transgendered people I have known have been some of the most courageous people I have known. They deal with this relatively little-known medical problem of gender dysphoria, face harsh discrimination in some cases, sometimes go through potentially painful and expensive procedures to correct the mismatch between gender and sex. It must take a great amount of self-knowledge and perseverance. The best we can do as a society is understand the issues, understand the medical problem, and make it so that the only obstacles they face are only biological rather than cultural. If we work with 3000 year old prejudices or modern prejudices or are just uneducated and highly opinionated on the topic in general, then we're going to screw it up and cause harm.
What is considered 'mental illness' is fairly flexible and changing. While there are some clearly mentally unstable individuals for all sorts of reasons, the more subtle issues between the brain and the body require more nuance in understanding. Things like sexual attraction, gender identity, or talking with invisible beings can be considered by some cultures to be forms of mental illness while other cultures may do more research to understand them and learn to understand that some of those things are not mental illnesses at all. Research showed that homosexuality shouldn't really be considered a form of mental illness and was removed from being listed as such. Transgenderism has been listed under different names (with the most recent being a shift from 'Gender Identity Disorder' to the less explicit 'Gender Dysphoria') but is now very much treated as a physiological medical problem rather than something that needs to be altered in the mind.