I have a very good (in my opinion) theory why the Borg have had such a difficult time defeating the Federation. Here it is. The Borg are of a single mind. They work as a collective but a single mind is still limited to narrow thinking. They adapt and assimilate in order eliminate resistance. Unlike many powers in the Star Trek universe we have seen, Starfleet is made of up hundreds of classes of ships, each having their own abilities and types of weapons. This forces the Borg into a difficult position. Adapting to a single type of tech is easy. Adapting to many is not.