The best Borg episode was written by Michael Piller
The season three finale of Star Trek: The Next Generation, “The Best of Both Worlds,” was arguably one of the most shocking moments in Star Trek history. It was the first Star Trek cliffhanger ever as well as the first two-parter since The Original Series’ “The Menagerie.” So, for the first time in twenty-three years, fans had to wait to know what was going to happen to the Enterprise, Captain Picard, and the Borg cube. No one knew how the Borg, such an all-powerful enemy could be beaten. Turns out, neither did the writer.
“The Best of Both Worlds” was written by Michael Piller who had only agreed to stay with The Next Generation for one season. So he had every intention of leaving at the end of season three. He admitted [in Star Trek The Next Generation 365] that he had no idea how to beat the Borg because he had no intention of coming back when he wrote part one. In fact, he figured the resolution of Captain Picard’s assimilation and the danger the Enterprise was in with the Borg would be someone else’s problem.
But The Borg were still Michael Piller’s problem after all
After season three ended, Gene Roddenberry told Piller that the show needed one more year to “catch fire,” and he said it would mean a lot to him if Piller would return for one more year “to see it through.” Piller, of course, couldn’t say no, which meant the Borg became his problem once more.
And when season four was starting production, Piller was still trying to figure it out. To him, he had created an “unsolvable problem.”
"“And to be honest, as I started writing the second part of the cliff-hanger that was supposed to resolve the story, I just didn’t know what was ultimately going to beat them.”"
The resolution didn’t come to Piller until two days before filming was set to begin, and he said it was the crew that figured out how to beat them.
"“I didn’t discover it until the characters did. I like to stand back as a writer and let the characters speak, and I listen to them and sort of take notes.”"
According to Piller, he got the crew into the situation, but they got themselves out. And they did it very well as the two-parter episode remains one of the best in The Next Generation history, according to fans.