Young Villefort is the closest thing we get to a foil for Edmond. Like Edmond, he's young, he's lucky in love, and his job prospects are good. Oh, and in case the parallels weren't clear enough, his betrothal feast takes place at exactly the same time as Edmond's. The Villefort we're first introduced to is a man of principle. But when he's confronted with evidence that Edmond unwittingly holds against Villefort's father, Villefort chooses to have Edmond unjustly imprisoned. This is the moment everything changes: Villefort goes from being an impartial, honest young prosecutor to a scared, self-interested man. In contrast, Edmond becomes even more concerned with justice, and avenges himself against Villefort.
Dumas invites us to compare Mercédès and Haydée because these two lovely ladies are Edmond/the Count's love interests. Ultimately, in this novel, and in Edmond's mind, Mercédès is defined by having been disloyal – instead of honoring Edmond's memory and remaining single, she maries Fernand. Haydée, in comparison, remains entirely loyal to Edmond, and she is the woman that he will share his life with.