I'm curious as to how Arakawa ended up with the final episode. Didn't he typically do episodes that could be considered filler episodes?
For Megaranger, yeah, but remember that Takatera and a lot of staff on Megaranger were coming directly off of Carranger. I believe Arakawa wrote some of the milestone Carranger episodes for Takatera already, so Takatera probably had no reason to believe Arakawa couldn't write a good ending. Especially since, in a lot of ways, Megaranger comes off to me now as, "Let's try and do a show with Carranger's energy, but play things straight."
I can't remember off the top of my head if Arakawa wrote Carranger's final episodes or not-- but I know there's a really good, pretty plotty Carranger run he did where I was kind of shocked it wasn't Urasawa when I first looked at the credits. Arakawa may deserve a lot more credit for Carranger on the whole, and particularly how well it manages Sentai's traditional story beats, than he tends to get, honestly.
And this is something I've never exactly been too clear on: When exactly does pre-production start on these shows? At what point would Kobayashi juggle her Gingaman scripts with her MegaRanger ones?
It's hard to say because it's changed so much over the years. In the modern era, we pretty much know that they begin work developing next year's iteration sometime during the first quarter of the current series. That seems to be why the creative staff generally changes completely from year to year, so one team can be designing next year's stuff while this year's show is being made.
Back when Gingaman was made, it seems like everything was a lot more last minute. That said, for a writer as prolific as Kobayashi, I really doubt that developing Gingaman while she was writing Megaranger was all that hard. Remember that tokusatsu writers pretty much don't write anything for fight scenes, beyond major dialogue they want worked into the scene. So it's probably easier to belt out a Sentai script than a lot of other things. And it's not like she'd be developing the whole show's story bible single-handedly-- Takatera is infamously hands-on in that regard.