
A foil in storytelling parlance is a character with no particular status who is introduced into the story only to be a contrast to another, more popular character. This is much like Alfrid Lickspittle in The Battle of the Five Armies, where he is added to make Bard the Bowman look better and more noble.
Usually, a foil is a polar opposite. His/her purpose in the story is to simply exist. They don’t do any great deeds, or acts of valor. However, to have a good foil, the character you’re “foiling” has to be indisputably original, and your foil must be an opposite in every way.
However, there’s more than one way to contrast characters. Foils have a tendency to become “extra baggage” and to annoy the reader. Instead of using a foil, you could use a more advanced technique: creating a “foil” with more influence on the story.
Usually, the character you want to contrast is a main hero. The villain is, in every way, different from the hero. This is much like Robert Lewis Stevenson’s Treasure Island where Long John Silver is a polar opposite of Jim Hawkins. Silver is old, scoundrelly, and cowardly, whereas Jim is young, honorable, and brave.
What the contrast does for you is it puts more sympathy on the “good guy” and adds more of a “villainy” feeling to the bad guy. Sympathy for the hero is always good, because we want a hero that people can resonate with. Disgust for the villain is always good as well, because we all want a person that we can vent our frustration on.
This all stems back to the point that you need good heroes and bad villains. None of this “antihero” or “antivillian” garbage. In order to contrast well, and thereby build sympathy and disgust for your heroes and villains, you need to have clearly morally evil bad guys and morally good good guys.
Consequently, making opposite heroes and villains is good for only two people. What you could do is reflect on how these two heroes and these two villains are polar opposites in every way except one. For example, Luke Skywalker is naïve, not world-wise, mostly innocent, and principled. Han Solo is world-wise, not innocent, and not principled.
What I’m saying is that you can have two clearly moral good guys, but they can still be different. This is easier, because in the last example you had to sculpt both the hero and the villain in their actions so that they remained consistent. With this one, the heroes (or villains) are like enough to be similar, but different enough to be obvious. Try this in your own storytelling.
Writing about poral opposites can be a bit of an experiment, but it’s also quite fun. Especially the dialogue: You can almost predict where the chat will go next. Between contrasted characters, they feed off each other and they reinforce their personalities in turn. It’s like you have accountability partners: The opposite of this character will ensure that he/she unwaveringly makes these kinds of decisions.
Good luck, and happy writing!