I never quite expected Android 17 to show up and so late in the series. But at least showing up late gave him the opportunity for a decent story.
Android 17 spent most of his time protecting strong but vulnerable animals on some island. Goku barely manages to convince him to join the tournament of power.
He does decently well during the tournament of power. And just by luck alone, he remains the last fighter.
Thus he gets to wish upon the Super Dragon Balls. And with his wish, he brings back all the erased universes.
Though his sister Android 18 doesn’t understand why he made a wish so selfless.
But the Grand Minister reveals that his selfless wish was a test. If a selfish wish had been made, then Grand Zeno would have erased all the universes.