If instead of "keeping peace & justice in the Republic", the Jedi's task was "carrying a couch"...
About 1,000 years prior to The Phantom Menace, the Jedi see the Senate trying to get the couch off the ground and go:
Jedi: "Uh, need some help?"
Senate: "Oh God, yes please...!"
Jedi: "Cool, what's the plan?"
Senate: "You carry the back end, we carry the front and lead the way. It'll go smoothly from here."
And for a solid millennium, this arrangement works and the couch moves forward without ever being dropped.
But by the time of the Prequels, the Senate has stopped carrying their end. Instead, they're sitting on the armrest, on their phone, online gambling or taking selfies for their InstaStories, they're having fun, talking with their buddies. They're being irresponsible and absolutely self-serving.
So the Jedi are in a situation where they have to PUSH the couch alone because if they don't, that's it, the couch is dropped.
And it's SUPER difficult, but hey, at least the couch is moving, right? Dunno for how much longer they can keep this up, though.
As this goes on, a Sith Lord sees this entire ordeal and decides to JUMP on the couch, speeding up the clock on the inevitable drop.
Then the Clone War happens, which is the equivalent of the Jedi needing to keep trying to push the couch using only ONE hand, while they use their other limbs to fight off the Separatists and get that Sith Lord off the couch.
Then Order 66 happens, the Jedi are dead and the couch is dropped.
Mission failed, "long live the Empire".
Now, this is just an analogy simplifying the events.
If we go by what George Lucas said on the Jedi's role in the Republic, there's quite a few differences between "carrying a couch" and the Jedi's ordeal.
For instance, it's not just the Jedi carrying the other end of the couch, there's also people like Bail and Padmé (otherwise the couch would've stood still a while ago).
Also, when you're helping someone carry a couch, you can just walk away if the other guy acts like a jerk.
But in the case on the Jedi, they can't just walk away because they pledged themselves to the Republic. They made a vow and a system has been built around it, they can't just up and leave or say "no, fuck you Senate, we out". Because the principles of the Republic are worth upholding and the system works when the Senate isn't filled with douchebags, as shown by the fact that there was peace and prosperity up until the Prequels.
Finally, in the analogy, moving the couch only benefits the other guy, right?
But in this case, the Jedi's role in the Republic actually helps everyone, which is why the Jedi joined in the first place. If they leave, they'd be abandoning the people of the Republic.
Point is, the Jedi are not meant to be seen as "the elite" or "the establishment" by the audience. They're the underdogs.
They're pretty much the only ones still trying to do their jobs right and everyone around them has stopped giving a crap.
So saying "the Jedi failed" is redundant. Who wouldn't fail?
Which is why George Lucas never blames them, in his commentary about the Prequels. When he talks about what the Prequels are about, he never says it's about the Jedi's failure, he always blames:
the Senate for failing their duty to the Republic and giving it over to Palpatine with thunderous applause,
and Anakin, for failing to overcome his own personal flaws and giving in to his greed.
Sure, the Jedi are not perfect, but nobody ever said they were. Because while their failure is a plot element, it's not meant to be a focal point.