St. Thomas's Commentary is odd on this text. The version of the Commentary available online doesn't have the Latin of the Biblical text St. Thomas used, so I don't know what text he was reading. But the text he was reading apparently mentions both factions
and heresies. He writes, "Thirdly, he assigns the reason for their credulity, saying: For there must be not only factions among you but also heresies. Two things must be considered here: first, what heresy is; secondly, how it is necessary that there be heresies."
So as you can see, his subsequent commentary is going to focus on the bit that doesn't seem to appear in the contemporary text--the mention of heresies. About that (in dealing with the second point mentioned above), he writes:
Secondly, it must be considered how it is suitable that heresies exist. For if it is suitable for heretics to be, it seems that they are commendable and should not be stamped out. But it should be noted that there are two ways in which something is described as suitable to be. In one way from the intention of the one who does this; for example, if we should say that judgments ought to be, because judges make judgments intending to establish justice and peace in human affairs. In another way from the intention of God Who ordains evil things to good, Who directs the persecutions of tyrants to the glory of the martyrs. Hence Augustine says in Enchiridion that God is so good that He would not permit evil in any way, unless He were powerful enough that from each evil He can draw some good. And according to this it says in Matt (18:7): “Woe to the world for temptations to sin. For it is necessary that temptations come, but woe to that man from whom temptations come.” And according to this the Apostle says the heresies must be, inasmuch as God has ordained the malice of heretics to the good of the faithful. He says this, first, for the clearer declaration of truth. Hence Augustine says in The City of God: “A question raised by an adversary is an occasion for learning; indeed, many things pertaining to the Catholic faith, when they are devised by the clever energy of heretics, in order that they may be defended against them, are considered more carefully and understood more clearly and preached with more emphasis.” Hence it says in Pr (27:17): “Iron sharpens iron; and one man sharpens another.” Secondly, to reveal the weakness of faith in those who believe rightly. And this is what the Apostle says: in order that those who are genuine, i.e., approved by God, may be recognized among you: “Like gold in the furnace he tried them” (Wis 3:6).
That last bit is confusing in its own right. What does it mean to say that God allows heresies "to reveal the weakness of faith in those who believe rightly"? I assume it's something like the heresy gives them the opportunity to recognize that they haven't grappled adequately enough with the doctrines of the Faith, and to further pray and study to protect themselves from being led astray. Something like that? But I dunno.
The question, I guess, is whether these same considerations would explain why it is suitable that factions exist. I think it is obvious that St. Thomas thinks so. That factions of the relevant sort arise as a result of heresies. So the two things are in a sense one thing. If that's so, then you can apply his reasoning above to the question of what he thinks about the necessity of factions. Dunno if that makes it clearer, but perhaps it's at least encouraging that he is saying more or less what you yourself proposed as a possible interpretation in the OP.
