First, let's look at a little more context:
9 Two are better than one, since they have good reward for their toil.
10 . For if they fall, one will lift up his friend, but woe to the one who falls and has no second one to lift him up.
11 Moreover, if two lie down, they will have warmth, but how will one have warmth?
12 And if a man prevails against the one, the two will stand against him, and a three- stranded cord will not quickly be broken. (From Chabad)
Rashi gives the following explanations (see there for more; I'm focusing on your specific question):
Two are better: in all respects.
And if a man prevails against the one: If bandits came upon him to prevail against him, if they are two, they will stand against him, and surely, if they are three, for a three-stranded cord will not easily be broken. Another explanation: Whoever is a Torah scholar, as well as his son and his grandson, the Torah will never cease from his seed, and so Scripture states (Isa. 59:21): “shall not move from your mouth or from the mouth of your seed or from the mouth of your seed’s seed.” Another explanation:
and a three-stranded cord: in Bible, Mishnah, and good manners-will not quickly sin. “There is one, and there is no second,” is expounded in the Midrash in other ways, but the sequence of all these verses does not fit in with them.
Kohelet Rabbah offers several other interpretations. I'm summarizing from the Soncino translation. (Sefaria has Hebrew but I didn't find English there.)
Two are better than one when they study Torah together; the threefold cord refers to the teacher who corrects their mistakes for them.
Two are better when they transact business together, and the threefold cord refers to when there are three partners.
R' Yochanan said: two are better refers to man and wife, and the third is the Holy One blessed be He, who grants them children.
R' Yehudah says the two are David and Batsheva and the third is Natan the prophet.
R' Nechemiah said: two are better refers to Yehoiada and Yehoshabeath, and the threefold cord is the Sanhedrin which agreed with them (II Chron. XXIII, 11).
The Rabbis said: two are Mordechai and Esther, and the third is Achashverosh who agreed with them and issued the decree for the Jews.
R' Levi b. Chama said in the name of R' Chanina: "two are better" means the two whom Mordechai and Esther caused to be hanged, "than one" means the one whom Yosef caused to be hanged, becuase through the former miracles were performed for all Israel, and "a threefold cord" is the Holy One, blessed be He, who caused the enemy to fall (referring to hanging Haman).
R' Zeira seems to be saying that it refers to families -- a family of scholars will produce more scholars, and so on down through the generations (and also for other types of families, like rich ones). There's an objection that sometimes the children of rich parents struggle more, to which he replies that a threefold cord is not quickly broken, not that it never is.