It could be due to some sort of experiment gone wrong. There might have been a magical experiment in the wizarding world that accidentally affected Harry's emotional capacity. For example, if there was an attempt to enhance his magical powers but it had unforeseen side effects on his emotions.
Maybe he was cursed by a dark wizard. Some powerful curses can mess with a person's emotional state.
Well, it would likely make his friendships very strained. His friends might feel constantly shut out. For example, when they're excited about something, Harry's lack of emotional response would be off - putting. They might start to doubt if he really cares about them at all.
It might be related to his Sacred Gear. If there is some sort of malfunction or unforeseen side - effect of his Sacred Gear, it could lead to this situation. For instance, if his power is growing in an uncontrolled way, it could disrupt his normal bodily functions including sexual ones. Fanfiction authors often play with such concepts to create interesting plot twists.
One possible reason could be a powerful jutsu gone wrong. Maybe he was hit by an enemy's attack that was specifically designed to numb his senses. Another reason might be some kind of psychological trauma. For example, if he witnessed something extremely horrible, his mind might have shut down his ability to feel as a form of self - protection.
One possible reason could be to protect himself from the pain and loss he has endured. After all he's been through, like the death of his parents, Sirius, and so many others, turning off his emotions might seem like a way to avoid further hurt.
One possible reason could be to explore a different side of the character. By taking away his emotions, the writer can show how much emotions actually contribute to his actions and relationships. It's like a 'what if' scenario.
It could be a very different take on the Harry Potter universe. Without emotions, the characters might seem robotic. For example, Harry's fight against Voldemort could be more like a strategic battle without the emotional drive of revenge or protecting his friends. It would be a cold, calculated world where magic is just a tool and not something that is tied to the characters' feelings.
It could also be related to his self - preservation in the wizarding society. In a world full of magic and danger, showing too much emotion might be seen as a weakness. Harry, being aware of this, decides to shut out his emotions to appear stronger. He has faced a lot of scrutiny and jealousy from some students and even some adults in the wizarding world. By suppressing his emotions, he hopes to be more respected and less of a target.
One possibility is that the fanfic changes Snape's backstory to make him more sympathetic. Harry, being empathetic, then feels safe around him. For instance, if Snape's past is shown to be full of hardships that made him act the way he did, Harry might understand and feel safer in his presence.
It could be Voldemort. Even if he's defeated, his actions might have left such deep scars on Harry. For example, all the people he killed and the destruction he caused. Harry might feel responsible for not being able to prevent more deaths and this guilt could make him lose the will to live.
Perhaps it's an old enemy that was thought to be defeated. This enemy might have been biding their time and finally finds a way to get revenge on Harry by driving him mad. It could be a Death Eater who was overlooked or a creature from the Forbidden Forest with a grudge.