A character foil is one that contrast with the other character. In the case of Ivan he was weak and ill on his way to death, so Gerasim contrasted his character by showing strength and health, this appears in the part where Gerasim came in with strong bare young arms and later showing health and vitality.
The two sentences that show this contrast and Gerasim as characters foil to Ivan are in option 2. and 4.
2.Gerasim with a firm light tread, his heavy boots emitting a pleasant smell of tar and fresh winter air, came in wearing a clean Hessian apron, the sleeves of his print shirt tucked up over his strong bare young arms;
4.Health, strength, and vitality in other people were offensive to him, but Gerasim's strength and vitality did not mortify but soothed him.