A foil character is either one who is in most ways opposite to the main character or nearly the same as the main character. The purpose of the foil character is to emphasize the traits of the main character by comparison or contrast.
A foil is a secondary character who contrasts with a major character; in Hamlet, Laertes and Fortinbras, whose fathers have been killed, are foils for Hamlet. Or in The Crucible by Arthur Miller, Abby and Elizabeth Proctor.