Luke thought he could take down Vader because he was his father’s kid, and had enough training. He was severely mistaken. He lost a hand, couldn’t save his best friend Han, and endangered Leia and the rebellion with his presence alone. Not only does he stay on track with his original mission statement, despite having every virtue and preconceived notion questioned, despite having his mentors be liars in his eyes, despite being so lost in the world, he was ultimately strengthened by his own failure and came out a better person on top. That’s a moral I can personally abide by, and it’s hardly an unrealistic thing.
Luke then thinks he can train Ben Solo, despite sensing the Dark Side throughout his training. He was severly mistaken; he lost his nephew to a powerful Dark Side Force user and felt like he betrayed Han and Leia, although they would disagree. Han himself thought Luke was a more reputable person to be trusted with turning Kylo back from the dark than he was, Leia thought it possible because he was a Jedi, and Luke didn’t agree. And now despite being a wiser, more mature human being who’d been through many worse things in the past, he opts to flake on his mission statement and let much worse things happen from his inaction than had ever happened from any of his direct actions. Because he’s…insecure? If the reasoning really was that he felt he stood to lose even more, then he’d first prevent more loss from occurring while he was still readily available to do so. But he doesn’t because the script requires him elsewhere for reasons that were undeveloped prior to actually putting him there.
Functionally it’d be more sensible to have him go there to mediate, to find the precise moment to reintroduce himself to the conflict in order to ensure the “brightest timeline” so to speak. And in his meditation he begins to doubt whether he’s committed to the right course of action, but before fully following through, it takes Rey, a young adult who has been through near-identical trials and tribulations, to truly connect and bring him out of his hole.