A foil is a character which illuminates the positive and negative qualities of a main character. Krogstad does this for Torvald in that they have many of the same experiences and skills but they respond very differently to crisis. Krogstad highlights Torvald's selfishness and cold heart. When faced with financial difficulties, Krogstad committed a crime in order to get out from under them. He acknowledged his crime and worked very hard to redeem himself in the eyes of the community. However, Torvald would not forgive Krogstad for his past indiscretions and fired him. In response, Krogstad threatened to tell Torvald that Nora, Torvald's wife, committed a similar crime. He changed his mind about blackmail when he found love, but he was too late. When Torvald discovered that Nora committed a similar crime to Krogstad's, he was unforgiving and rigid with her too. The fact that Nora committed her crime in order to prevent Torvald's death was immaterial to him. Motives do not matter to Torvald. There was no instinct, as Nora had hoped, that Torvald would offer to take or share the blame as Nora committed her crime for his sake. Essentially, Torvald's relationship with Krogstad highlights Torvald's inability to forgive and his unwillingness to endure hardship for the sake of love.
Krogstad, an employee at Torvald's bank, knows Nora forged her father's signature and has been deceiving Torvald. Krogstad threatens to tell Torvald if Nora doesn't convince her husband not to fire him, not realizing that Nora has no influence on her husband. When Krogstad leaves the letter for Torvald about Nora's deception, the letter serves to show Nora that her husband is a self-centered, selfish hypocrite. Torvald is only concerned about his reputation when he reads what Nora has done. Krogstad then sends another letter to Torvald, saying he will not bring legal action against Nora, showing he's trying to make up for his previous actions. After this, Torvald feels better and wants to forget the whole episode, but it is too late. Nora now sees Torvald for what he is and leaves him and her children. Krogstad's first letter is the reason why Nora leaves in the end because it finally opens Nora's eyes. The second letter shows Nora what a hypocrite Torvald is since he's willing to forget everything after Krogstad says he won't be bringing legal action.