Basically, they both wanted to do it, how boring
I'm still surprised Hyrule Warriors exists and it's not because of the gratuitous cleavage. My favorite Zelda director, Eiji Aonuma, is apparently supervisor on the Tecmo project, which is being produced by Hisashi Koinuma and Yosuke Hayashi. They talked with Famitsu, as translated here by Siliconera, about how the collaboration happened.
"Warriors has teamed up with series such as Gundam, Fist of the North Star and One Piece, and I thought about doing something with Nintendo," explains Koinuma. "While thinking about what would make for a good collaboration, it was Hayashi that proposed [the idea] by saying, 'Wouldn't it be interesting to do a collaboration with The Legend of Zelda?'"
They spoke with Eiji Aonuma and Shigeru Miyamoto, whom agreed on the collaboration. Aonuma apparently considered the idea of a cross over years ago when Tecmo announced the One Piece game. "Miyamoto told me, 'The folks at Tecmo Koei are talking about a Zelda Musou. Are you interested?'" Aonuma said, "and I responded with 'definitely!'"
"You can say that luck also played a role," Koinuma said. "The title that our company wanted to do a Musou game collaboration with the most just so happened to be the one title that the folks at Nintendo said 'we can entrust them with this one' to, so we were both able to come to an agreement regarding The Legend of Zelda."
There you have it. Still weird. I wonder if this will lead to more Warriors/Nintendo cross-overs. I mean, not like Nintendo is interested in making Star Fox games itself.