Heroic Javert
The ambush at the Gorbeau tenement, while long, is important in a lot of ways. Not only is it a turning point for Thénardier, Valjean, and Marius, but it shows a side of Javert that we don’t see very often: the heroic protector of society.
We see him pursue Valjean across the years in service of an unjust law.
We see him persecute Fantine on the say-so of someone who just happens to look more respectable than she does.
We see him infiltrate the uprising (though to be fair, that’s a matter of perspective — he’s only the “bad guy” because the rebels are our viewpoint characters).
Here, placing him against Thénardier and Patron-Minette, we see Javert at his best. There’s no moral ambiguity. They’re the bad guys, he’s the good guy, and he’s actually pretty damn badass. It’s what sets an antagonist apart from a flat-out villain, and what gives him a depth of character that makes him almost appealing.
It reminds me of something J.Michael Straczynski said about Bester, the Psi-Cop played by Walter Koenig on Babylon 5: After a few appearances, “the next time we saw him, he either had to win, or he had to be right. If he lost again, it’d cut his credibility out.” Without this scene, Javert remains a caricature, a symbol of law as villain. With it, we see him win and be right, and we get to see that his personal view of himself isn’t completely self-delusion.
Javert’s problem is that he sees the world in such black-and-white terms that everyone who has transgressed, however minor, becomes a criminal in his eyes, worthy of punishment rather than protection. Himself included, as seen when he confesses to M. Madeleine that he’s denounced his superior. (It must have been such a relief to learn that he’d been right all along about Madeleine’s identity.) And in the end, that’s what kills him.