Dr. Rank serves as dramatic foil to both Torvald and Nora. But more than that, his situation actually directly parallels Nora's own, which helps to portray the theme of injustice that's dominant in the play.
Dr. Rank serves as dramatic foil to Torvald in the way that he treats Nora as an equal while Torvald does not. It is evident in the very first act just how friendly Dr. Rank is with Nora. He is so friendly that he is even aware of Nora's school friends' names while Torvald is not. We see this when Dr. Rank is first introduced to Christine Linde and says to her, "I have often heard Mrs. Linde's name mentioned here" (I). Later, we learn that Dr. Rank knows Christine's name while Torvald does not because Torvald is so jealous of Nora that he can't even stand to hear her talk about her past acquaintances from home. So instead, Nora converses with Dr. Rank about her past friends and family. This level of familiarity and friendship that Dr. Rank has with Nora while her husband does not shows us just how much Torvald treats Nora as a possession rather than as an equal human being.
Dr. Rank also serves as Nora's dramatic foil in that Nora allows her rebellious side to show around Dr. Rank. In Dr. Rank's presence, Nora openly eats her macaroons and even offers them to Dr. Rank and Christine, even though Dr. Rank well knows that sweets are forbidden in the house. Also, in the presence of Dr. Rank, Nora dares to say something as "shocking" as "Well, I'm damned!" (I). Since Nora is rebellious around Dr. Rank, but obedient and submissive around Torvald, this shows us Dr. Rank acts as her dramatic foil.
However, more importantly, Dr. Rank's situation parallels Nora's, which helps to capture the theme of injustice. Dr. Rank is unjustly dying young because of his father's lack of self-control. It is said that his father's indulgences contributed to Dr. Rank's poor immune system. Dr. Rank expresses that he feels it is unjust that he should have to pay the penalty of dying young because of "another man's sins" (II). In the same way that Dr. Rank is suffering injustice, so is Nora suffering the injustice of society, which helps portray the theme of injustice.