Dr. Rank is often overlooked in analyses of A Doll's House. This is most likely because he... doesn't do much.
None of his actions directly affect the action of the play. He's in love with Nora, but that goes nowhere. Nora considers asking him for money, but then decides against it. Even Rank's impending death doesn't really affect the action in any major way: his supposed friends briefly lament him, then continue on with their domestic squabbling. So why is Dr. Rank in the play at all? Ibsen knew a thing or two about writing plays. He must have had some purpose for Rank, right?
The first function we see Dr. Rank fulfill is providing a little exposition on Krogstad. Rank tells Nora and Christine that Krogstad "suffers from a diseased moral character" (1.247). The good doctor goes on to relate Krogstad's history as a criminal and blackmailer. This function doesn't seem to totally justify Rank's existence in the play, though. Another character could've just as easily got that information out to the audience.
Rank's talk of moral disease and his own affliction are often cited as symbolic. He has tuberculosis of the spine. This could possibly be meant to represent the diseased backbone of unenlightened society, a society where men and women don't live as equals. His death also could be seen as symbolic. It comes at the same time as the "death" of the Helmers' marriage. The two ideas are linked when the cards with black crosses come in the same mailbox as Krogstad's marriage-shattering letter.
It seems that Rank's most important purpose in the play is to reveal things about other characters. His relationship with Torvald reveals Torvald's superficiality. This is shown when Rank decides not to tell Torvald directly about his impending death. Rank tells Nora, "Helmer's refined nature gives him an unconquerable disgust at everything that is ugly; I won't have him in my sick-room" (2.152). The doctor knows his friend well and is aware that Torvald has a child-like horror of anything remotely unattractive. Statements like this show that Torvald may be the sheltered one in the Helmers' relationship.
Rank's relationship with Nora gives us one of our first big clues into the distance that truly lies between the seemingly perfect Helmers. Nora says that her husband "used to seem almost jealous if I mentioned any of the dear folk at home, so naturally I gave up doing so. But I often talk about such things with Doctor Rank" (2.44). It's pretty telling that Nora is only able to reveal her true self to Rank. Nora also admits to Rank that "being with Torvald is a little like being with papa" (2.217). This is a pretty major statement and, without Rank there, Nora never would have said it.
All in all, it seems that the doomed Dr. Rank is really around just to help us learn more about the main characters.