It’s the final battle of Good vs Evil, so the Sith mastermind seems like the perfect character to drop in, and further raise the stakes.
Palpatine was the overarching villain of the first two trilogies, so it makes sense that he would factor into the franchise’s conclusion.
While Palpatine’s role in The Rise of Skywalker was originally a shock to the generations of fans, J.J. Abrams has explained his inclusion ahead of the movie’s debut.