A foil in literature is a term used to describe a character who is both similar and very different from the protagonist, and who is there in order to highlight particular qualities of the main character.
In the play Hamlet, the protagonist, Hamlet, has several foils, including Horatio, Claudius, Laertes, and Fortinbras.
In my opinion (which may or may not differ from yours), Hamlet's main foil is Laertes. Laertes is Ophelia's brother, so Hamlet and Laertes share their love for the same woman (although not the same kind of love). They both share passion for revenge (their fathers have been murdered - Hamlet's father was killed by Claudius, and Laertes' father was killed by Hamlet). The difference between them is that Laertes is very active in trying to find his father's murderer and have his revenge, whereas Hamlet is rather passive, pondering thoroughly on his next course of action, and thus wasting time doing noting.