Building on the previous answer, another great example of foils in Great Expectations is Miss Havisham and Magwitch. Though initially, these two characters seem to have nothing in common, it must be noted that Pip believes one is his benefactor, while the latter actually is his benefactor. Both characters are not what they seem.
One might assume that Miss Havisham is Pip's benefactor because she is wealthy, high-bred, and seems to want Pip to be with Estella. One might assume Magwitch is just a no-good criminal because of the initial impression he makes. But in truth, Miss Havisham is selfish and cruel (even though she eventually has a change of heart), while Magwitch has depths of compassion one would not expect of an intimidating convict.
For all her money and breeding, Miss Havisham lives most of her life as a bitter, unkind woman, while the poor Magwitch is much more generous, despite his criminality. Dickens is making a comment on the idea that one's class is a reflection of one's heart or potential for goodness.