A dramatic foil is a character who may be similar or in parallel circumstances compared to the main character of the story. In this way, the dramatic foil is meant to serve as a basis of comparison with the main character, thereby enhancing the audience's perception of the main character's most important personality traits or actions.
Sidekicks can be a kind of dramatic foil. They oftentimes accompany the hero, so they share a parallel path of action in the story. However, a foil doesn't necessarily have to hold similarities with the main character.
Foils serve the purpose of comparison, of highlighting the important aspects of the main character. Because of this, a sidekick may have opposite personality traits to the main character. This helps the audience perceive those differences in the main character.
Similarly, the villain can be seen as the foil to the hero. The presence of the villain highlights why the hero is different. There are many examples of this in literature. In Mary Shelley's "Frankenstein," Dr. Frankenstein and his creation are foils to one another.
There are numerous reiterations of the dramatic foil concept, and they don't have to be conceptualized as sidekicks or antagonists. In fact, any story that has multiple characters can have multiple foils, all serving to create comparisons with one another, and therefore serving to highlight important depths in the characters.