Here's an interview with Rian Johnson:
So, can I just make the statement, that's who her parents are? They came from nothing, they're buried in the desert, is that for sure?
First, this is from just days after The Last Jedi released in 2017. Rian knew from the get go that this may easily not be the final say on Rey's family.
Second, the point, as he said, was for her to hear the most difficult thing she could hear in that moment. And in that moment, Ben wanted her to feel totally isolated, like all she had was him. Kylo can't even know for sure who her parents actually were, he's guessing, or at best, going by some vague childhood memories he saw in her mind. Kylo is telling Rey this to try to break her.
If Rise of Skywalker had said, no, Rey is a Skywalker or a Solo, that would have been a betrayal of what Rian was trying to do. That would have been the undo button that just made things easier for her. Instead JJ adds a new element, something that is even harder to Rey to deal with. That her grandfather was perhaps the most evil man in history. It's something that makes her feel inherently flawed, so much so that she's willing to exile herself like Luke did because she believes she's too dangerous to the galaxy.
Rey's entire arc has been driven by longing for family, and has been about moving past her biological family and becoming her own person. This is why Rey Palpatine and coming face to face with the Emperor at the end of trilogy is completely perfect. Here at the end of her arc is the utter rejection of her grandfather. Palpatine tells her that he is all the family he has, preying on her longing for her family. To finally be united with her last living family member and for him to be completely evil is her most difficult test, and is the natural conclusion to Rey's trilogy-long arc. It's no longer just that anyone can be special, it's that anyone can be good.