I had a story idea planned out once, but I never finished it. Instead of having the Gym Badges be a filler, they were, as NoirGrimoir stated, an excuse to journey. But they only started the journey. Eventually, the protagonist focused less on the Gym Badges (eventually deciding to stop striving for them), and more on defeating the antagonist, who was using the world's legendaries to shape the world the way they wanted. In the end, the protagonist got too much power, and Uxie had to give her amnesia to prevent her from abusing it.
Anyway, my story purposely strayed from the initial goal set in the beginning parts, moving on to a new goal as the story progressed.