Master Yoda was supposed to be this badass Jedi yet he loses against Palpatine. Meanwhile Master Mace Windu almost beats Palpatine, and would have, had it not been for Anakin's intervention.
So what gives? Why couldn't Yoda beat Palpatine?
As Null points out, your question is probably flawed, in that Windu didn't actually beat Palpatine, and it is likely that Palpatine allowed Windu to disarm him. However, I'm willing to answer the question as you asked it, and address the real version of events afterwards.
To answer the question as it was asked:
It isn't specifically stated, but we can speculate that it is the result of several factors.
Mace uses lightsaber form called Vaapad, which he himself invented. It was frowned upon by the Jedi Council because it skirted the edge of the Dark Side of the Force and required that the practitioner bend, if not actually break, the generally accepted rules of conduct for Jedi. In fact, Windu is the only Jedi practitioner of Vaapad who didn't fall to the Dark Side of the Force.
Mace Windu was a formidable warrior and generally considered one of the greatest swordsmen ever produced by the Jedi Order. He was a master of all seven forms of lightsaber combat. He began his development of the deadly form of combat known as Vaapad, the seventh form of combat which completed (to the Jedi) the Juyo form. Vaapad was named after a predator native to the moons of Sarapin.
Mace Windu was the only Jedi to fully master Vaapad. The other two practitioners of the style, Sora Bulq and Depa Billaba, were unable to master it—instead, it mastered them, driving them insane and leading them to the dark side. It is said that only his onetime friend, Dooku, and the venerable Grand Master Yoda could outspar him. When he went to Haruun Kal in search for his former Padawan, Depa, he used both his and her lightsabers in a masterful two-bladed variant of Vaapad. During his duel with Darth Sidious, he and the Sith Lord used a Form V opening stance in the middle of the battle, but it is unknown whether or not Mace Windu employed Form V. A factor that played into Windu's fighting style was his admission that his greatest character flaw was his enjoyment of fighting, and given the nature of the dark side, this was a very dangerous trait for a Jedi to possess. In fact, Windu intentionally created Vaapad to help channel his inner darkness into something more positive. He also often employed a behind the back parry and then thrust sequence in his dueling style.
Windu was one of the greatest swordsmen of his time. He defeated Sora Bulq during their duel on Ruul and overpowered Asajj Ventress shortly afterwards. Windu also fought on par with Count Dooku during the battle of Boz Pity and even managed to defeat Darth Sidious himself in a duel— a feat that no other Force Adept, including Grand Master Yoda, was ever able to accomplish unaided. Another notable example of Windu's fighting skills was that he was able to overwhelm the powerful cyborg General Grievous, though the latter did put up a considerable fight.
"I created Vaapad to answer my weakness: it channels my own darkness into a weapon of the light."
- Mace Windu to Obi-Wan Kenobi
"[Vaapad] is very aggressive... It can take the user very close to the dark side..."
- Mace Windu
"Vaapad is as aggressive and powerful as its namesake, but its power comes at great risk: immersion in Vaapad opens the gates that restrain one's inner darkness. To use Vaapad, a Jedi must allow himself to enjoy the fight; he must give himself over to the thrill of battle. The rush of winning. Vaapad is a path that leads through the penumbra of the dark side…This was Vaapad's ultimate test."
- Mace Windu
Vaapad was described as more than a fighting style; it was a state of mind that led through the penumbra of the dark side, requiring the user to enjoy the fight, and relish the satisfaction of winning. The practitioner of Vaapad would accept the fury of their opponent, transforming them into one half of a superconducting loop, with the other half being the power of darkness inherent in the opponent. The form was also mentioned with a cautionary warning by the Jedi that use of Vaapad led the user perilously close to the dark side due to its focus on physical combat. Vaapad required a constant and sizable stream of Force use from the user, with a barely contained explosion of Force power essential to all variations of Form VII as another prerequisite for its use. The form's attacks appeared to be unconnected, its motions seemingly unpolished to an untrained observer.
During the later years of the Republic, Jedi Master Mace Windu developed Vaapad with the aid of fellow master Sora Bulq, by drawing inspiration from the movements of a creature, known as both the Vaapad and the Juyo, native to the planet Sarapin. Vaapad users appeared to wield many lightsabers at once, moving too fast to see, just as the vaapad creature would attack with blindingly fast tentacles that were impossible to count until the vaapad was dead. A Vaapad user's attacks would flow into each other with liquid precision, creating the constant near-invisible weave of energy which was the ready-stance of Vaapad. It was also possible to apply Vaapad in unarmed combat, with the user's arms becoming too fast to see, as well as in the use of dual lightsabers. While observing the duel between Darth Sidious and Mace Windu, Anakin Skywalker considered Windu's Vaapad bladework to be "an oblate sphere of purple fire" which contained dozens of blades attacking from every angle.
After his fall to the dark side prior to the Clone Wars, Count Dooku described the power of Vaapad as skirting the dark side of the Force, but stated during a duel with Sora Bulq that the form was bridled and weak without direct use of the dark side. Dooku later subverted Bulq to his cause. After Bulq fell to the dark side, he claimed that he had perfected the form, which Windu disputed while engaging Bulq in a lightsaber duel. While Bulq had previously practiced Vaapad with Windu, he was unable to defeat him in combat and their duel ended in a stalemate. Though Windu and Bulq were credited with the creation of the Vaapad variant, the seventh lightsaber form was known, albeit obscurely, by the name Vaapad as early as the end of the New Sith Wars by the Sith Blademaster Kas'im.
Thus, Windu was fighting fire with fire, so to speak, and battling the Emperor on his own terms. Vaapad allowed him to channel the Emperor's hostility and aggression back at him, using his own energy to defeat him. Windu was also considered to be one of the most talented lightsaber combatants who ever lived, so it isn't particularly surprising that he was better suited to fight Palpatine than Yoda was.
Yoda was a master of lightsaber combat, and was widely acknowledged as being perhaps the greatest Jedi duelist of his time despite being trained as a Jedi Consular. It was said that only Mace Windu, Count Dooku and Palpatine were able to fight with him on equal terms. Although a master of all forms, his preferred style was Form IV, as it allowed him to compensate for his limited reach and stature. His technique was said to consist of the pure basics of Ataru taken to their highest possible levels. Despite his age, Yoda was an exceptional swordsman, displaying amazing speed and dexterity, leaping through the air and twirling as he battered at an opponent's defenses. Much of his lightsaber combat style relied on jumps and acrobatics, augmented by his mastery of Force Valor. Despite the fact that Yoda's primary combat specialization was Ataru, he demonstrated an extreme level of skill with regard to deflecting blaster bolts.
"Form IV, also called Ataru, is the most acrobatic Form, filled with numerous elaborate moves, and relies heavily upon a Jedi's ability to run, jump, and spin using the Force."
- Cin Drallig
Ataru was an aggressive combat form relying on a combination of strength, speed, and agility. Due to this, it was also called the Way of the Hawk-bat or the Aggression Form. Practitioners of Ataru were always on the offensive, attacking with wide, fast, and powerful swings. Form IV practitioners constantly called upon the Force to aid in their movements and attacks. By allowing the Force to flow throughout their body, they could overcome their physical limitations—including old age, as was the case with Master Yoda—and perform amazing feats of acrobatics, such as somersaults and backflips, not only for attack, but also to evade the slashes and strikes of their opponents. Jedi utilizing Ataru needed to incorporate all the Force powers that involved surpassing normal physical ranges of motion, speed, and agility in order to be successful. Running, jumping, and spinning were all emphasized in learning the elaborate kinetics of the form.
Those who used Form IV could move at high speeds and could rain strong blows, jumping and attacking through the air. Powerful and quick spinning attacks could be utilized from all angles, either from ground or air. A master in Ataru combat could appear like a blur to their opponents, attacking from all directions—the front, the sides, overhead, or behind. The Force not only allowed them to perform athletic feats not possible otherwise, but it also helped guide their actions and movements in combat.
Yoda is centuries old, walks with a cane, and is near the end of his life. Windu is a young man, relative to Yoda, and in better shape.
In his later years, Yoda lost a great deal of his mobility, demonstrating a pronounced limp and depending on a cane to aid him in his everyday movements. This loss of mobility was due to the fact that, in his old age, Yoda suffered from debilitating arthritis. When possible, Yoda preferred to use a hoverchair rather than walk at all. His mastery of Force Valor allowed him to overcome these physical infirmities, but due to the extremely taxing nature of the ability, he was only able to utilize it for a short time before tiring.
"To use Vaapad, a Jedi must allow himself to enjoy the fight; he must give himself over to the thrill of battle. The rush of winning."
- Mace Windu
Due to his talent as a duelist and Force-user, Windu was very prideful, quite secure in his own strength, and he was especially well known for a sharp tongue and an occasional sarcastic interface. However, he kept this arrogance in check for the most part, humbling himself towards individuals he felt superior, such as Yoda.
Ultimately, Mace Windu's true motivation for all he did was a divergence from Jedi philosophy, as his personal belief system was an extremist viewpoint of peace at all costs*. In his mind, peace was created by civilization, and he viewed the Republic as the ultimate civilization, thus developing an attachment towards the institution, and leaving him with a willingness to do anything required to preserve the Republic, even if it meant violating Jedi philosophy. This proved to be his ultimate downfall, when he resolved to execute the seemingly helpless Chancellor Palpatine, an unarmed opponent, spurring Anakin Skywalker into action.
Yoda: "Help you I can. Yes, mmm."
Luke: "I don't think so. I'm looking for a great warrior."
Yoda: "Oh! Great warrior. Wars not make one great."
- Yoda and Luke Skywalker, meeting on Dagobah
To his students, the elfin luminary Yoda could appear as either very strict or like a grandfatherly figure, testing them to mental and physical extremes one moment and showing warmth the next. Students often strongly disagreed with him at first, but gradually came to understand his attitudes.
Among his colleagues on the Jedi High Council, he was known to have a penchant for mischief and practical jokes. To all of the young Jedi, he was the humble Yoda, who offered enlightened leadership and epitomized the ideals of the Jedi Order; a grandmaster of that august body, he was widely known as a sage instructor.
Yoda wasn't able to defeat Palpatine - or fare as well against him as Windu did - because of a number of factors:
His age and physical infirmity, relative to Palpatine and Windu.
His outlook on the use of the Force, which led him to reject overt aggression and hostility. Windu was willing to kill an unarmed Palpatine, which is something that is difficult to imagine Yoda doing.
His inability to meet Palpatine on equal footing, in terms of the use of Dark Side energies.
Speculatively, when Yoda fought Palpatine, he may have been hindered by the greater damage that had been done to the balance of the Force in general and the Jedi Order in particular, relative to the situation when Windu fought Palpatine.
It is likely that Palpatine wasn't as beaten as he appeared to be. The novelization of Revenge of the Sith suggests that Palpatine deliberately let Windu "defeat" him because he knew that Anakin would intervene on his behalf [the following quote is redacted to focus on the relevant information]:
Now the shadow was only Palpatine: old and shrunken, thinning hair bleached white by time and care, face lined with exhaustion.
"For all your power, you are no Jedi. All you are, my lord," Mace said evenly, staring past his blade, "is under arrest."
"Do you see, Anakin? Do you?" Palpatine's voice once again had the broken cadence of a frightened old man's. "Didn't I warn you of the Jedi and their treason?"
"Save your twisted words, my lord. There are no politicians here. The Sith will never regain control of the Republic. It's over. You've lost." Mace leveled his blade. "You lost for the same reason the Sith always lose: defeated by your own fear."
Palpatine lifted his head.
His eyes smoked with hate.
"Fool," he said.
He lifted his arms, his robes of office spreading wide into raptor's wings, his hands hooking into talons.
"Fool!" His voice was a shout of thunder. "Do you think the fear you feel is mine?"
Lighting blasted the clouds above, and lightning blasted from Palpatine's hands, and Mace didn't have time to comprehend what Palpatine was talking about; he had time only to slip back into Vaapad and angle his blade to catch the forking arcs of pure, dazzling hatred that clawed toward him.
Because Vaapad is more than a fighting style. It is a state of mind: a channel for darkness. Power passed into him and out again without touching him. And the circuit completed itself: the lightning reflected back to its source.
Palpatine staggered, snarling, but the blistering energy that loured from his hands only intensified. He fed the power with his pain.
"Anakin!" Mace called. His voice sounded distant, blurred, ; if it came from the bottom of a well. "Anakin, help me! This is your chance!"
He felt Anakin's leap from the office floor to the ledge, felt his approach behind - And Palpatine was not afraid. Mace could feel it: he wasn't worried at all. "Destroy this traitor," the Chancellor said, his voice raised aver the howl of writhing energy that joined his hands to Mace's blade. "This was never an arrest. It's an assassination!"
That was when Mace finally understood. He had it. The key to final victory. Palpatine's shatterpoint. The absolute shatter-point of the Sith. The shatterpoint of the dark side itself.
Mace thought, blankly astonished, Palpatine trusts Anakin Skywalker...
Now Anakin was at Mace's shoulder. Palpatine still made no move to defend himself from Skywalker; instead he ramped up the lightning bursting from his hands, bending the fountain of Mace's blade back toward the Korun Master's face.
Palpatine's eyes glowed with power, casting a yellow glare that burned back the rain from around them. "He is a traitor, Anakin. Destroy him."
"You're the chosen one, Anakin," Mace said, his voice going thin with strain. This was beyond Vaapad; he had no strength left to fight against his own blade. "Take him. It's your destiny.'"
Skywalker echoed him faintly. "Destiny..."
"Help me! I can't hold on any longer!" The yellow glare from Palpatine's eyes spread outward through his flesh. His skin flowed like oil, as though the muscle beneath was burning away, as though even the bones of his skull were softening, were bending and bulging, deforming from the heat and pressure of his electric hatred. "He is killing me, Anakin—! Please, Anaaahhh—"
Mace's blade bent so close to his face that he was choking on ozone. "Anakin, he's too strong for me—"
"Ahhh—" Palpatine's roar above above the endless blast of lightning became a fading moan of despair.
The lightning swallowed itself, leaving only the night and the rain, and an old man crumpled to his knees on a slippery ledge.
"I... can't. I give up. I... I am too weak, in the end. Too old, and too weak. Don't kill me, Master Jedi. Please. I surrender."
Victory flooded through Mace's aching body. He lifted his blade. "You Sith disease—"
" Wait—" Skywalker seized his lightsaber arm with desperate strength. "Don't kill him— you can't just kill him, Master—"
"Yes, I can," Mace said, grim and certain. "I have to." "You came to arrest him. He has to stand trial—" "A trial would be a joke. He controls the courts. He controls the Senate—" "So are you going to kill all them, too? Like he said you would?"
Mace yanked his arm free. "He's too dangerous to be left alive. If you could have taken Dooku alive, would you have?" Skywalker's face swept itself clean of emotion. "That was different—"
Mace turned toward the cringing, beaten Sith Lord. "You can explain the difference after he's dead." He raised his lightsaber.
"I need him alive!" Skywalker shouted. "I need him to save Padme!" Mace thought blankly, Why? And moved his lightsaber toward the fallen Chancellor.
Before he could follow through on his stroke, a sudden arc of blue plasma sheared through his wrist and his hand tumbled away with his lightsaber still in it and Palpatine roared back to his feet and lightning speared from the Sith Lord's hands and without his blade to catch it, the power of Palpatine's hate struck him full-on.
He had been so intent on Palpatine's shatterpoint that he'd never thought to look for Anakin's.
Dark lightning blasted away his universe. He fell forever.
Your premise -- that Windu would have beaten Palpatine if not for Anakin -- is fundamentally flawed, because there is a confounding factor: Palpatine almost certainly threw the fight against Windu in order to seduce Anakin to the dark side.
Palpatine was confronted by four Jedi Masters and quickly dispatched three of them with ease, leaving only Windu. Palpatine and Windu fought to a draw until Anakin arrived, and only then did Windu suspiciously "defeat" Palpatine, "forcing" Palpatine to appeal to Anakin to save him (because Palpatine allegedly has the power to save Padme, which Anakin desperately wants). Here's how it is described by the script:
A close shot of PALPATINE as the fight begins. Close shots of THREE JEDI getting cut down by PALPATINE. PALPATINE and MACE continue to fight.
Jedi Master MACE WINDU and the Sith Lord fight their way down the hallway and into the main office area. PALPATINE is able to use the Force to slam MACE against the wall, but he recovers before the Chancellor can cut him down.
ANAKIN lands his speeder, jumps out, and runs down a long corridor toward the Chancellor's office.
In the heat of battle, MACE cuts the window behind the Chancellor's desk, and it crashes away. MACE is forced out onto the ledge, which is twenty stories up. They fight over the precipice. ANAKIN arrives to see PALPATINE and MACE fighting.
They stop as MACE forces PALPATINE to drop his sword. PALPATINE and MACE start yelling at each other.
MACE WINDU: You are under arrest, My Lord.
PALPATINE: Anakin! I told you it would come to this. I was right. The Jedi are taking over...Come to your senses, boy. The Jedi are in revolt. They will betray you, just as they betrayed me...Don't let him kill me...I have the power to save the one you love. You must choose. You must stop him.
Palpatine had long been grooming Anakin for seduction by the dark side, and had told him that the Sith knew how to prevent a person from dying (which Anakin wanted to know in order to save Padme). Palpatine forced Anakin to choose the Sith over the Jedi for precisely that power, but he could only do so by throwing the fight. And Anakin did just as Palpatine planned: Anakin killed Windu and turned to the dark side -- a win-win for Palpatine. On the other hand, if Palpatine defeated Windu on his own he'd only have to fight and kill Anakin as well.
If Windu only "defeated" Palpatine because Palpatine let him, then Windu fared no better against Palpatine than Yoda (arguably worse, since Yoda at least survived).
Yoda was defeated by Palpatine for the same reason Windu and the other Jedi Masters were killed by Palpatine: the Jedi were complacent (this is a common theme throughout the prequel trilogy) and knew next to nothing of the Sith plot (or even that Palpatine was a Sith!) until the last minute, whereas Palpatine had a long time to prepare for his fight against the Jedi; Palpatine was prepared, but the Jedi were not. To quote Sun Tzu:
If you know your enemies and know yourself, you will not be imperiled in a hundred battles... if you do not know your enemies nor yourself, you will be imperiled in every single battle.
Also, dark side > light side :).
It's dangerous to assume that a strict "X is greater than Y" ranking system for Force users must necessarily dictate the outcome of any conflict. Other factors come into play. We may observe Anakin vs. Obi-Wan as an example of this.
In the case of Yoda vs. Palpatine, it seems worthy of note that Palpatine first attempted to flee:
"If so powerful you are, why leave?"
Yoda's defeat in that battle comes down to several factors which can be observed in the film. First, he was deprived of his lightsaber by Palpatine blasting it out of his grasp right after he completed his leap to Palpatine's pod. By contrast, Mace was able to hold on to his saber under Palpatine's barrage. Next, after Yoda blocked Palpatine's lightning with his bare hands, the resulting Force stalemate built to an explosion which blew each of the combatants backwards. Palpatine was able to grab onto his pod's handrail; Yoda was flung down to the rim of a central podium with no handrail, and thus ended up falling to the floor of the chamber, still without his lightsaber. Yoda knew that he had to flee at that point, because clone troopers were on the way.
That is why Yoda lost the fight -- although the true, out-of-universe reason is of course that he had to, for continuity's sake.
As far as the Mace vs. Palpatine fight is concerned, it's worth noting that George Lucas said Mace overpowered Palpatine and indicated that Palpatine was really trying to "destroy" Mace. So Palpatine might not have actually thrown the lightsaber duel as many seem to think.
This is the moment that defines Mace Windu.
Not his countless victories in battle, nor the numberless battles his diplomacy has avoided. Not his penetrating intellect, or his talents with the Force, or his unmatched skills with the lightsaber. Not his dedication to the Jedi Order, or his devotion to the Republic that he serves. ( Revenge of the Sith novelization )
This is a good question, but I don't think the answer is hard to find.
Yoda is very strong in the Force and a master swordsman, but Sidious is just a frail old man with dark space-wizard powers. Sidious might be one of the strongest Sith of all time, but probably not as strong as Bane. He is greatly skilled with his lightsaber, but much much powerful in the Force, he's actually one of the Sith lords that can move past the point of using a lightsaber, but still keep one. The Sith believe with their power one should be able to use the Force as their only weapon.
See, Sidious let Windu "best" him in his dying battle. It's more than fair to assume Sidious could sense Anakin coming. He lets Anakin get there to see him about to die at Windu's hands so he can get Anakin to kill one of his Jedi masters fully pushing him to the Dark Side where Anakin dies and Vader is born.
It might appear that Yoda didn't put up as much a fight as Windu but in reality he most likely did better. Even though it's widely accepted that Yoda was the most powerful Jedi of that time it's not crazy to for him to lose to Sidious. The dark side is about power; all Jedi miss out on power they could gain by being a Sith, some levels of Force power just isn't reachable without hate, passion, and rage - all components of the Dark Side. Sidious was just too much in the end but Yoda was still able to survive the battle, it was more or less a tie because we know Sidious would have loved to killed the great master Yoda.
It's really not a crazy thing to think about, and let's not forget to brass tax to all this... It's writing. The story had to have Yoda lose and survive: no Sidious - no episodes IV-VI. If Sidious kills Yoda, who completes Luke's training? The story had to get there some way and personally I like the way it did.
Palpatine clearly respected Yoda's power: he tried to run instead of fight, and during the saber portion, when Yoda was superior in his blade work, Palpatine broke off and got distance. This is the key: Windu overpowered Palpatine because the sith was not able to distance himself from his Jedi assailant. Had the duel stayed in that office Yoda most surely would have emerged the victor.
Here's my take on it --Yoda was extremely powerful in the force and would have gained the upper hand if it hadn't been for his extremely vulnerable position on the Senate Pod- Palpatine was clearly being overpowered by Yoda in their force lightning battle with the latter most likely would have been perceived as the slight winner if he hadn't been so small and at the very edge of the pod.I think at that point Palpatine would have fled and ultimately succeeded- there's even a Youtube video of an alternate version of their fight that shows exactly that. But as the fight turned out, Yoda was at a disadvantage due to his size and made the strategic, although self-disparaging decision to leave the fight.
Going on, I believe Yoda was very ill prepared for Sidious's first lighting attack- it was REALLY obvious what Sidious was about to do. I do not believe he was knocked unconscious by it though. Anyway, I also think that Palpatine's pod attack took a toll on him though because towards the end of it, after getting closer to Sidious , he was forced to dodge one and then another which he did extremely narrowly, throwing off his aim,and thus making him fall onto the pod, have to rest for a second due to his old age, and be forced to get up again to hurl the pod at Sidious.
I also truly believe that Yoda did disarm Sidious because if you look closely, there is a lightsaber near Yoda when he falls down to the floor of the Senate Chamber and although it doesn't match either of their weapons , the image of Yoda's falling lightsaber doesn't look anything like it at all, therefore making it Sidious's lightsaber by default with a continuity error on behalf of the CGI Animators. Although the continuity error could apply to Yoda's saber as well, I do not think that is the case given how close in time Sidious's disarming of Yoda and Yoda's fall are. So, I think we can definitely state that Yoda disarmed Sidious and although we may never know exactly how Sidious reacted/got to the Senate Pods, we are forced to conclude that the novelization and G.L's original script's scenarios are correct. (I don't have the quote for the novelization--can someone post that here?)