I am not even addressing the Rambam and the rules that only a man can take the throne. That goes without saying. Since part of the definition of Mashiach is that he will take the throne and his children will continue to hold it, the mashiach cannot be a woman. However, I address other logic as well below.
Since the Mashiach will be a king and will have children who will be of the lineage of King David, then he cannot be a woman. The children of any women are of the lineage of the husband. Thus, since the next king must be a child of a king, then a queen's children would not be able to be of that lineage. The rules for a king are similar to those of a kohen.
I explained in another answer, which kings must Moshiach descend from?, how the Mashiach needs to be a descendant of Zerubavel because once each king takes the throne, then the lineage continues through him. The circumstance in which Tzidkiyahu became the king was very unusual and the Tanach does not even consider that the lineage could have continued with him. We also see with Athaliah that she was never considered legitimate when she killed all of her grandchildren (except for Yoash) even when it was not known that he was alive.
Since the lineage must be father to son from Zerubavel, then the queen and the king could not both be of the same lineage. Only one particular line from Zerubavel would have led to the mashiach. Once the mashiach is revealed, any one else (from a different line of fathers) would have been shown to be ineligible. For the king and queen to be of the correct lineage would make them brother and sister (even if from different mothers).
Note that the promise that the line would continue means that the mashiach would have children and the kingship would continue in his descendants.
Leadership (as with Devorah) is not inherited as opposed to kingship and kehuna..