Rey is a Sith time traveller from 3,471 ABY who had travelled back to 41 BBY in order to destroy the prophesied chosen one, Anakin Skywalker, and create a Sith empire. She was succesful in her time travel, but Jar Jar Binks, who was actually a secret time traveller bounty hunter, manipulated Rey’s travel and she ended up on Jakku instead of Tatooine. Jar Jar then cast a magic Force spell, because he’s also Force senestive, that made Rey stumble and hit her head on a rock, which cause her to lose her memory. Thus she is stuck on Jakku for about 75 years until the events of Episode 7. Palpatine then returns because he used his time travelling Force abilities at the end of Episode 6 and thus didn’t die, and he tries to persuade Rey to take up her mission once again. But thanks to the power of Force friendship, Rey becomes the strongest Jedi-Sith hybrid to have ever existed and thus banishes Palpatine into the Force realm of alternative universes. This is not without its consequences, as Rey needs to travel back to Tatooine during around 41 BBY in order to banish Palpatine for good. Before that however, Rey and Kylo Ren (who’s now Ben Solo again because he also leaned the Force ability of friendship) fucked, so Rey is actually pregnant by the time she is back on Tatooine in 41 BBY. She decides to take the name of Shmi Skywalker and call the baby Anakin Skywalker.