According to a 2020 article from USA Today, even though the character had plunged into the heart of Starkiller Base, Ford had been approached by Abrams to come back for the brief scene:
“When JJ asked me to do it, I said, ‘Are you kidding? I’m dead!'[…] He said, ‘Sorta dead. You can do this.’ He hadn’t written anything at that time. But he said, ‘This is going to be great.’ So I said okay. If JJ asked you do something, you’d probably do it too. He’s a very persuasive guy.”
On top of that, he also saw this as a good opportunity to give a boost to the emotional journey of Kylo Ren. “It was a useful addition to the story and the continuing development of Adam Driver’s character.[…] And the chance to do another scene with Adam was great,” says Ford.
Back when Ford was making the press tour rounds for “The Force Awakens,” his answer to coming back as Han jokingly involved the mention of money. When Jimmy Fallon asked him if the character’s return made him emotional, he hilariously responded with “no, I got paid.” The payday for “The Rise of Skywalker” was likely too big to turn down, but I can also see him having a great deal of respect for Abrams and Driver. In terms of why Han would return, his presence felt like the best alternative that didn’t involve dredging up Carrie Fisher’s likeness.