This play by Henrik Ibsen was first performed in the nineteenth century, which is important for historical context. At this time, women had few more legal rights than children, which is a key source of conflict in the plot.
Torvald Helmer is a character without many qualities to elicit compassion in the audience. He refers to his wife with insulting pet names, diminishes her opinion, and ridicules her. It would be easy to assume, therefore, that the audience can foretell the ending of the play.
But it's not quite as simple as that. First, Nora is incredibly invested in her marriage both early in the play and, presumably, beforehand. She has taken great risks to illegally acquire money for her husband's medical treatment and has concealed the truth from him to ensure his acceptance of the money (and thus to save his life). She is a mother who seemingly loves her children, playing with them as visitors enter.
Additionally, in Nora's historical context, women simply didn't have any other choices. Most could not work jobs, especially ones that could provide for a family. Men were deemed responsible for women's financial affairs; thus, Nora had no possible way of saving or investing any hypothetical money she did manage to earn. And, as seen in the play, women could not even borrow money in their own names. What, then, were women expected to do in unhappy marriages? They were expected to dig deep and make it work.
That is why audiences were so shocked at Nora's departure at the end of this play when it was performed. Ibsen was considered an anarchist for his portrayal of a woman choosing to leave her husband, and men and women alike were greatly offended by the way she speaks to her husband.
Has this stereotype completely vanished from modern American society? Of course not. Women often choose (for a myriad of reasons) to remain in marriages where their partners are verbally abusive and/or emotionally irresponsible. And often, there is still an expectation that women must simply make the best of this.
Historically and today, Nora's decision to leave comes as a shock considering all she has done to help her husband and considering the ways women are traditionally viewed in relationships.