Foils are characters that highlight each others' characteristics through comparison and contrast, just like a sixth-grade essay.
For example, King Argaven doesn't accept Ai's offer, because he's afraid the Ekumen (3.69). The Commensals boot Ai into the Volunteer Farm for the same reason—fear. Here's the difference. Argaven worries about what Ai's invitation to the Ekumen will mean for his country, and he can't see beyond that. The Commensals fear the consequences of Ai's mission will lessen their power or make them look like idiots (11.53).
In both cases, fear is what drives these characters, but it drives them for different reasons and to very different actions.