In any narrative, a foil is a character who contrasts with another character, typically, a character who contrasts with the protagonist, in order to better highlight or differentiate certain qualities
Don Quixote and his sidekick Sancho Panza, as illustrated by Gustave Doré: the characters' contrasting qualities are reflected here even in their physical appearances