A foil is a character who exists to provide contrast. Macbeth and Macduff are opposites. Although both are brave soldiers and noblemen when the story starts, Macbeth becomes a murderer and a tyrant and Macduff vows to stop him.
Macbeth is the Thane of Glamis and Macduff is the Thane of Fife. Both are important nobles to the kingdom, and both are apparently loyal to Duncan.
Macduff is everything Macbeth is not. He is sensitive and emotional. When King Duncan is murdered, he is horrified while Macbeth—Duncan’s murderer—only pretends to be.
O horror, horror, horror! Tongue nor heart
Cannot conceive nor name thee. (Act 3, Scene 3, p. 34)
He also asks people to look after Lady Macbeth when she seems to faint. He is concerned with her health and safety even as the king is dead. This is completely contrary to Macbeth, who thinks only of himself.
Macduff seems aware that Macbeth is up to something. He becomes suspicious. Banquo says he suspects something.
Against the undivulged pretence I fight
Of treasonous malice (Act 2, Scene 4, p. 37)
Macduff replies: “And so do I.”
Clearly, he suspects foul play. It is not much of a step from there to suspecting Macbeth, in whose castle Duncan was killed.
From there, tragedy strikes. When Macbeth reaches out and has Macduff’s wife, son, and entire household killed, the two are fated to struggle to the death. Macduff cannot let such an insult stand.
Malcolm, who has been feeling Macduff out to see if he really is loyal, tells Macduff to “dispute it like a man” and he says he will, but he still feels it.
But I must also feel it as a man.
I cannot but remember such things were,
That were most precious to me. (Act 3, Scene 3, p. 74)
Of course, Macduff is not the treacherous one. He is determined to kill Macbeth in order to return justice and peace to the land. He cares as much about his country as getting his revenge.
In the end, one foil often ends up killing the other. Macduff kills Macbeth, the violent version of himself, because he has gone to the dark side. He has turned evil. Macduff feels responsible for taking him out.
Behold where stands
The usurper's cursed head. The time is free.
I see thee compass'd with thy kingdom's pearl (Act 5, Scene 8, p. 90)