Luke doesn’t want anything to do with Rey. He solemnly drops the 'saber to his feet (rather than doing a comedy toss over his shoulder).
He’s actively investigating the first Jedi Temple, searching for the lost archives, hoping there’s a key in there to defeating the Dark Side once and for all—the original Jedi were able to keep the Sith underground for over a thousand generations, after all… But now, they’ve taken over the galaxy TWICE in the last 60 years.
Through a combo of tech and Force ability, Luke is breaching the Temple, a few levels deep now. Something goes wrong with the tech, the entrance (or whatever) starts to close, Luke tries to hold it all together but can't-- until Rey steps in at the last second, and they do it together. He sees something special in her and agrees to let her stay. They’ll figure out the next steps together, and in return for her help with the troublesome tech ("I'm an experienced farmer, an ace pilot and a Jedi Master... But I never was much of an engineer") Luke agrees to give her some BASIC lessons, but no more until he gets his answers. Besides, what’s a master without an apprentice?
There’s riddles and Force based booby traps etc. Rusted but seemingly unbeatable guard droids (where they eventually realise the most Jedi'ish way of defeating them is to stop fighting entirely, and the droids let them pass).
They train in the meantime— Luke teaches her not just how to connect to the Force, but how to LISTEN to the Force, lightsaber defense etc. They go through stage after stage, deeper into the Temple. The whole time, we mostly see the same Luke we know-- full of hope and enthusiasm... yet somehow, just off slightly. Rey can sense it, too, and says as much to Chewie and Artoo (who help where they can).
One night, after a particularly challenging stage/on the eve of reopening the archives, he’s not just looking for a key to fixing the Jedi path, and defeating the Sith... He's looking for the Journal of the Whills aka the source of the Chosen One prophecy. Like Luke said, the Jedi kept the peace for over a thousand generations, but have fallen twice in 60 years... and what was the common denominator in those twin falls... The emergence of the Skywalkers. Anakin and Ben were supposed to be the greatest of them, but both fell, both helped cause untold destruction. Rey protests-- for all Anakin's misdeeds, he did right in the end. And Luke himself is good. That's when Luke confides in her that he himself almost slipped, and that cost him Ben.
As much as Rey is searching for her place in things, Luke is searching for his and his whole families. For the first time, we realise we’re not just seeing his usual sense of hope and enthusiasm… but actual desperation... He's at the end of his tether. Rey wants answers for him more than she does for herself now.
One last combined effort. Luke and Rey breach the archive. Luke is emotionally overwhelmed, and thanks Rey for helping him get here, without her it would not have happened. Luke approaches the old books... brimming with lost Jedi knowledge from a thousand generations before... but one book in particular seems to call to him-- the Journal of the Whills. Luke touches it, and is thrown into a vision.
It shows him the First Jedi, his First Padawan… The Temple and Council… the first CONFLICT. It shows the Jedi winning… and losing. Their first major defeat. It shows the Jedi’s secret cunning… their arrogance and their hubris…. Leading to their creation of a stronger Jedi… a form of Jedi their traditional, ingrained values wouldn’t accept…. their creation of the SITH. Designed to be their very secret weapon when the Jedi ways failed them. But, of course, they lose control. The Sith strikes out on his own. Then trains another, and another… The Jedi go to war against these monsters of their own creation. The fallen Sith swears he’ll return, says the Jedi have shackled themselves to the Light… Swears he no longer serves the Force, but the Force serves him… and one day there will come a Sith so powerful he can create… life itself. An image of Vader flashes and Luke rips himself out of the vision.
Luke, out of breath, in full on nervous breakdown. There’s no saving the Jedi, they were broken and hypocritical from the outset… and the Skywalker’s are the bastard children of their secret shame.
“It’s time for the Jedi to end”.
They argue, Rey leaves. Luke goes to burn the Temple, Yoda appears--
Luke: Did you know?!
Yoda: Mmm…. Suspicions, I held. Proof, I did not. To focus on the problems in front of my nose, I chose.
Etc, etc.
And Luke comes to realise (and tell Rey... because it's bizarre they don't have another scene together in TLJ) that he now realises it doesn't matter where or who you're from, but that you make the choice to be and do good every day etc. You choose your own path.