Well, perhaps in the fanfiction they leave because of a prophecy. A prophecy might state that their presence near Hermione would bring great danger to her or to the wizarding world as a whole. So, they sacrifice their friendship and leave. Also, it could be due to some dark magic influence. They are forced by a powerful dark magic spell to stay away from Hermione, not having control over their actions.
In some fanfictions, it could be a character development thing for Ron and Harry. They might feel that they have become too dependent on Hermione and need to grow on their own. So they leave to have their own adventures and find themselves. It could also be that there is a new character who has some sort of influence on them and convinces them to leave Hermione behind for what they believe are greater purposes.
Another reason could be a misunderstanding. Maybe he overhears something Harry and Hermione say and misinterprets it as them not wanting him around anymore. So, in a fit of anger and hurt, he leaves. This can lead to a lot of angst and drama in the fanfiction as the other characters then have to figure out how to get him back.
One possible reason could be a misinterpretation of their relationships. Maybe the author wants to explore a different dynamic where Harry and Hermione bond over Ron's perceived flaws, like his occasional laziness or his insecurities that might come across as annoying to them in this fictional scenario.
Power could be a reason. If there's a chance for Ron and Hermione to gain a great deal of power by turning against Harry, some fanfictions might explore this. For instance, a new dark power might offer them something they've always desired, like the ability to reform the wizarding world in their own image. They might think Harry would oppose this, so they betray him to get what they want.
It's possible that Harry hates it because he has a certain image of Ron and Hermione in his mind. Fanfiction can sometimes create versions of them that are completely different from what he knows. For example, some fanfiction might focus on a love triangle that he doesn't think exists in their real relationship. This divergence from his perception could lead to his dislike.
Another possibility is that the fanfiction writer wants to explore a different side of their relationships. By having Hermione and Ron hurt Harry, it shows the complexity of human (or in this case, wizard) emotions. It could be a way to show that even the strongest friendships can have cracks and that mistakes can be made. It also allows for character development as Harry has to deal with this new situation, and Hermione and Ron may later realize their mistakes and try to make amends.
It could be that Harry has been influenced by some external force. In fanfiction, there could be a new dark wizard or a magical object that is affecting his mind. This new influence might make him think that Ron and Hermione are in danger if he stays close to them, so he ignores them to keep them safe.
Some people might just want to explore alternative scenarios for the sake of creativity. They may think it's interesting to see how the story would unfold if there was animosity between them.
It could be due to a misunderstanding. Suppose Ron overhears a conversation between Harry and Hermione that he misinterprets completely. He might think they are plotting against him or don't really consider him a true friend. So in a fit of anger and hurt, he decides to betray them.
One reason could be envy. Hermione is often very good at academics and magic, and Harry and Ron might be envious of her success. For instance, if Hermione always gets top grades in potions class while Harry and Ron struggle, they could lash out at her out of frustration.
One reason could be jealousy. Maybe Ron feels that Harry is getting too close to Hermione and he's afraid of losing her attention. In fanfiction, authors often play with the characters' emotions. Harry, on the other hand, might see Ron as being too possessive of Hermione.