Well, it could be that a spell goes wrong. In the fanfiction world, spells can have all sorts of unexpected consequences. So a spell that Harry or someone else casts accidentally combines with some ancient magic that has a connection to the Rinnegan. This causes the Rinnegan to manifest in Harry. Another way could be that Harry discovers an ancient artifact in the wizarding world that has some sort of link to the Naruto universe, and when he touches it, he gets the Rinnegan. This then sets off a whole new adventure for him as he has to learn to control this new power.
Some fanfictions might suggest that there is a hidden part of Harry's magic that has a connection to the Rinnegan. It could be something that was passed down in his family unknowingly. Maybe one of his ancestors had some sort of encounter with a being from the Naruto universe long ago. And as Harry grows and faces different challenges, this hidden aspect of his magic activates, and he gets the Rinnegan. Then he has to figure out how to use it in the context of the wizarding world, like how it interacts with his wand and the spells he already knows.