Madame Forestier is a foil for Madame Loisel because she has the position in society that Madame Loisel wishes she had.
A foil is a character that provides contrast for the main character, or an important character.
The protagonist is Madame Loisel. She is the wife of a clerk, but she wishes she was more.
She dressed plainly because she could not dress well, but she was unhappy as if she had really fallen from a higher station; since with women there is neither caste nor rank, for beauty, grace and charm take the place of family and birth.
Madame Forestier is a wealthy friend of Madame Loisel’s from school. She has the life Madame Loisel wishes she had. When Madame Loisel complains to her husband that she can’t go to the ball because she has no nice jewels, he has a suggestion.
"How stupid you are!" her husband cried. "Go look up your friend, Madame Forestier, and ask her to lend you some jewels. You're intimate enough with her to do that."
Madame Forestier has money and jewels. She lends Madame Loisel a supposedly very expensive necklace so that she can continue the charade, going to the ball to show off. Madame Loisel loses the necklace and has to borrow money to replace it. She then finds out years later that the necklace was fake.
The foil is effective in this story because we see who Madame Loisel wants to be. She envies her friend, and in trying to become her loses the only advantage she has- her beauty and youth.