The return of Palpatine was always part of the plan. George Lucas was even brought on board for the project before they wrote the script.
From Star Wars Theory:
The Rise of Skywalker Teaser Trailer showed us that Palpatine will indeed return. JJ Abrams has gone on to confirm that he’s back, in the flesh for real. George Lucas was brought on board for the project before they even wrote the script, according to JJ. In this old Star Wars book that was released when George Lucas was still the owner of Lucasfilm and Star Wars, before selling to Disney, it is revealed as to how Palpatine was going to return to take Anakin Solo…who I believe in this scenario could be Kylo Ren (taken after Jacen Solo). I believe Disney/Lucasfilm are combining ideas from legends and putting them all together.
The Return of Palpatine… but how?
George Lucas had a vision for how Darth Sidious would return. It remains to be seen how much of his original vision will find its way into The Rise of Skywalker. (Some even speculate Darth Plageius will factor in the Emperor’s return)