Understanding the term “foil” more fully will help you apply it here in Hamlet as well as other texts in the future. The Oxford English Dictionary is a good place to find out the range of meanings of any word, and with these in hand, the word is easier to use Here are a few definitions the OED provides for “foil”:
- Metal hammered or rolled into a thin sheet . . .;
- A sheet of the same . . . placed behind the glass of a mirror, to produce a reflexion;
- Anything that serves by contrast of colour or quality to adorn another thing or set it off to advantage.
Taking these meanings seriously we understand that in literature, a foil serves through contrast to reflect (think aluminum foil) or underscore or in someway call attention to the traits, often subtle, of another character—to set the character off (as a gemstone in a ring) so that we see his/her distinctive characteritiscs better—more clearly.
I do not know if you have access to the OED, but I provide the URL in case you do.
Of course, the most major foil is Claudius. His power hungry ways and lack of respect and leadership are contrasted with the dead King Hamlet, who was strong and just, and his son, Prince Hamlet, who is thoughtful and also wants justice.
Another "foil" is Ophelia. Ophelia and Hamlet love one another, yet in his decision to pretend madness, he has to treat her harshly. She, of course, does not understand how he could turn so hateful. Hamlet must weigh his decision of revenge against her love.
Another foil is Polonius. When Hamlet acts out his revenge, he accidentally kills Ophelia's father. Polonius, therefore, messes up Hamlet's plans and causes heartache and disruption.