There's some enlightenment philosophy going on here, viewing free will as though it were unlimited. Free will is not man's ability to do anything; free will occurs within providence, and it is limited to the options available to a man and it is also limited by providence and natural laws. Obviously free will does not mean that I can fly or that I am omniscient-- but it also means that I cannot act in a way that is contrary to providence, despite the fact that I may sin. For the Church to act in a way contrary to her nature and mission (that is, for the pope or the magisterium to teach error) is not something that is explained by free will, because it is contrary to providence. Now we, could speak of a hypothetical were God chose to create a Church that did teach error (inasmuch as he could allow such a thing) in the same way that we could speak of a hypothetical where God chose not to redeem us (and to instead simply leave us in our fallen state). But providence, as a matter of faith, (that is, as a fact taken on God's authority) is otherwise, and free will does not and cannot go against that. It is a matter of providence that God will protect his Church, and that is the same promise as infallibility.
Some may wish to interject that I am not sufficiently distinguishing between different "types" of magisterium. The distinction between the magisterium that can teach error and the magisterium that can't is a complete novelty. The term itself refers to the teaching body of the Church, and while we can sub-distinguish different expressions and manifestations of this (ordinary teaching, extraordinary teaching, papal definitions, etc.) office, infallibility extends to it broadly inasmuch as it extends to the pope and then diffuses.
First, Magisterium. Start with the truth that the magisterium never has, never can and never will teach error. This is the unmovable and unchangeable foundation forever. The magisterium is, literally, "the Church teaching". The Church is Christ, Christ can never teach error. The pope and/or hierarchy are humans, they are not the Church. Being humans, the pope and / hierarchy can, have and do act contrary to the Church's nature of their own free will.
Second, Free Will. God does not interfere with anyone's free will. When we cooperate with God's graces, we do so of our own free will. Of our own free will, we can freely reject those graces and commit whatever sin we want to commit. Divine Providence means, literally, "God providing" and only influences our free will when we cooperate with grace.
God will never cease to protect His Church. Proof of this is abundant since He founded it 2000 years ago, the most resent proof is having +50 years worth of popes, hierarchy, lay people and all her enemies hell bent on destroying the Church, yet, the Church still reigns victorious as it will till the end of time.
Snip from a sermon given by Fr. Wathen:
...And even though there is much sin and there is real tragedy, the only real tragedy and the only irreparable tragedy of course being the loss of a soul. And this actually happens. But as far as creation is concerned and our part in it, we do not really recognize any tragedy because we anticipate salvation. We have no reason to disbelieve that Almighty God does not intend to save us. Not that we are unable to lose our own souls, but we recognize that we are serious about being saved. We intend to be and we have reason to rejoice that God has shown us such mercy.
Among all the mysteries that we live amongst, is that of the fact that God saves those whom He wills. And yet those who are lost are lost because they will. No one is saved against his will and no one is damned against his will. At the same time almighty God has known from all eternity who would be His whom he would succeed in saving. And all the jubilation that the Church expresses in it’s many Masses and in it’s office, is over the fact that those whom God regards as His elect will be saved.
Furthermore, no matter how much tragedy with which history is strewn, Christ moves towards His glorious triumph. With His resurrection was the announcement that He would have his victory, when he emerged from the tomb, He proved that there was no force, no power greater than He. And he proved that if he was invincible, then that which he would establish is also invincible, namely His Church. It really does not matter therefore that throughout history the Church suffer terrific blows, that it at times – and these times almost have always prevailed – that the Church suffer it’s terrible embarrassments, it’s setbacks.
Despite all this, despite all appearances and despite whatever losses, Christ is triumphing in the Church and He is proving His power, His invincibility and He is succeeding in doing what He came here to the world to achieve and God the Father is fulfilling the promises of His creation.
If it were not so, He would never have created anything to begin with. If it could be, that Almighty God could set in motion anything out of which He could not draw whatever He wished, then He would never had done anything like that and He indeed would not be infinite in the first place.
We have it in our power to participate or we have it in our choice to be turned away, it is strictly within our choice and whatever grace is necessary is within our grasp.