Eduyos chapter 4, mishnah 9 also deals with the laws of yibum, and it appears as well in Maseches Yevamos (chapter 3, mishnah 5). We will begin with two pieces of background, without which the mishnah cannot be understood.
First background - a shomeres yavam is like a married woman:
A woman whose husband died without leaving children falls to yibum: a 'zikah' is created between her and her brother-in-law, a bond that must be released through yibum or through chalitzah, and until then she cannot marry anyone else. This situation closely resembles a woman who has entered the first stage of marriage - kiddushin (erusin), in which the man gave her a ring, for she too is forbidden to every other man until the bond is released by a get or by the husband's death.
Because of this similarity, that both are equally forbidden to marry others, the Sages ruled that the status of a shomeres yavam is like that of a married woman. Consider: when a man betroths a woman, her relatives become forbidden to him as new arayos: before the kiddushin her mother and her sister were permitted to him, and from the moment he betrothed her they became forbidden to him forever - even though they are not blood relatives, they are like his own family and the laws of arayos apply to them. Similarly, the Sages ruled that a woman waiting for yibum is considered as though she were married to the yavam, and therefore her relatives too, her sister and her mother, become forbidden to him by rabbinic law.
Second background - what is a 'maamar':
The yibum itself is accomplished when the widow enters the yavam's bed, but prior to that there is an institution called 'maamar', which follows the pattern of kiddushin: just as before a man and woman live as husband and wife there is a first halachic stage of kiddushin - in which he gives her money, something worth money, or a document, and states that through this giving she is betrothed to him, designated for him and forbidden to every other man - so too the yavam performs a 'maamar' with the widow before the yibum.
The point of dispute:
The basis of the dispute in our mishnah is this: is maamar a rabbinic enactment, or does it carry force from the Torah? The mishnah brings this question to life through the case before us.
Setting up the case:
Reuven - married to Rachel.
Shimon - married to Leah, Rachel's sister.
Levi - the third brother, unattached, who is not married at all.
If Reuven and Shimon died without children, Rachel and Leah fall to yibum, and we have before us two separate mitzvos: Reuven's situation must be resolved through Rachel, by yibum or by chalitzah, and Shimon's situation through Leah. However, Levi cannot perform yibum with either of them, by rabbinic law: since he has a zikah with Rachel, he is considered rabbinically married to her, and Leah is forbidden to him as his wife's sister; and for that very same reason Rachel is forbidden to him, since on account of the zikah he is considered rabbinically married to Leah. He is therefore left with no option but to perform chalitzah with both of them. That is the basic case.
And now to the case of the mishnah: first Reuven died and left Rachel a widow - the only widow at this stage. Levi performed maamar with her: he gave her a ring and said that they were to be married through yibum, and she accepted. Afterward Shimon died, he too without children, leaving behind Leah as a widow.
Here the paths diverge:
If the maamar takes effect on a Torah level - then at the moment Shimon died, Levi and Rachel were already married at the first stage of marriage. Once Leah fell to yibum, she is not fit for Levi, who is already married to her sister, and therefore Leah goes free and is permitted to marry anyone, while Levi and Rachel complete the yibum.
If the maamar is only rabbinic - there is no real bond of marriage between Levi and Rachel, and we return to the basic situation: both women require yibum, each is bound to Levi by zikah, and each is forbidden to him rabbinically on account of her sister, so all he can do is perform chalitzah with both. And beyond that: since he made a maamar with Rachel, which is like marriage on a rabbinic level, Rachel will need - in addition to the chalitzah that releases her from Reuven's zikah - also a get from Levi on a rabbinic level, before she can marry another man.
So according to this approach: Rachel needs chalitzah and a get, Leah needs chalitzah, and Levi is left alone with no wife at all.
Let us look at the words of the Mishnah:
"Shelosha achim, shenayim mehem nesu'im shtei achayos, ve'echad mufneh" - Reuven and Shimon married the two sisters, Rachel and Leah, and Levi is unattached. Taken simply, he has no wife at all, and this detail is not essential to the law - even had he been married to a woman who was not their relative, the same rules would apply. The Mishnah chose the word "mufneh" because of the bottom line at the end, in order to highlight the tragedy of Levi being left alone.
"Meis echad mibaalei achayos" - Reuven died and left Rachel requiring yibum or chalitzah. "Ve'asah bah mufneh maamar" - Levi, the unattached brother, made a maamar with her: he gave her a ring and said that with this ring they commit to marry through yibum at a later date. "Ve'achar kach meis achiv hasheni" - before that date arrived, Shimon died and left another widow, Leah, who also requires yibum or chalitzah.
"Beis Shammai omrim: ishto imo" - Levi gets to keep his wife Rachel, since he made a maamar with her before Shimon died, and the maamar is valid on a Torah level, so they are married. "Vehalazo teitzei mishum achos ishah" - Leah goes free and is permitted to marry anyone, since she can never marry Levi, being the sister of his wife Rachel.
The source of Beis Shammai's position:
The verse in the passage of yibum (Devarim 25:5) says: "yevamah yavo aleha" - this is the mitzvah of yibum - and then adds: "ulekachah lo l'ishah." This addition seems superfluous, and the term "taking" is the very same term used for kiddushin: "ki yikach ish ishah." From here we derive a gezeirah shavah of "kichah" "kichah": the language of taking teaches that there is an acquisition similar to kiddushin. Therefore Beis Shammai hold that the maamar is the fulfillment of the verse's requirement - to acquire her with an acquisition of kiddushin before the yibum - and it is valid on a Torah level. For this reason Levi and Rachel were married through the maamar already before Shimon's death, and Leah, who was left a widow, has no option but to go free and marry another man, since the only brother left to her, Levi, is already married to her sister through the maamar.
"U'Beis Hillel omrim: motzi es ishto b'get u'vachalitzah, v'es eishes achiv bachalitzah" - according to Beis Hillel the maamar is only rabbinic, and has no force on a Torah level. Therefore both women, Rachel and Leah, still need to release their zikah to Levi; and since on a rabbinic level he is considered married to each of them, each one is considered his relative and forbidden to him rabbinically on account of her sister, so he cannot perform yibum with either of them, but must perform chalitzah with both.
With Rachel, with whom he made a maamar, two things are required: "b'get" - to dissolve the rabbinic marriage created by the maamar, "u'vachalitzah" - to release Reuven's zikah. And with Leah, the wife of his brother Shimon, only "chalitzah" is required, since yibum is impossible because of the rabbinic prohibition of a wife's sister.
"Zo hi she'amru: i lo al ishto v'i lo al eishes achiv" - this is the sad case about which the Sages used an expression of distress: "i" like "oy." Woe to Levi over his wife, for he loses Rachel; and woe to him over his brother's wife, for he loses Leah as well, whom he could have married had Rachel not been in the picture. He loses both of them, and that is the tragedy.
To sum up: Beis Shammai and Beis Hillel disagree as to whether ma'amar has the force of Torah law or is only rabbinic. According to Beis Shammai, his wife stays with him, and the second woman goes free and is permitted to marry anyone. According to Beis Hillel, Levi remains a bachelor, Rachel and Leah make their way as widows, and Reuven and Shimon have no one to perpetuate their legacy. This is why the Mishnah stated at the outset that Levi was "mufneh" - unattached: had he been married to another woman, the same rulings would have applied, but it would not have been such a tragedy for him, since he would still have had a wife. As it is, Levi is left with no wife at all - "oy lo al ishto ve'oy lo al eishes achiv" - woe to him over his wife and woe to him over his brother's wife.