In Victorian literature, marriage is often presented as the ultimate goal for a woman. To be an unmarried "spinster" is often viewed as a sad fate, one that leaves a woman unfulfilled, lonely, and vulnerable to poverty. In Jane Eyre, marriage has an important place in the story, but for Jane, marriage without companionship or possession of a sense of self is anathema to her development as a person.
Considering that Jane is orphaned and plain-looking, a marital alliance with the wealthy and passionate Rochester might seem to be the solution to her problems. Even with warning signs of his dominating nature early on in their engagement (such as Rochester insisting on buying Jane fine clothes and jewels that do not suit her sense of style), Jane still feels she will never be loved by anyone else if she does not marry him. However, when she learns about Bertha Mason's existence, two things become obvious to Jane.
Firstly, marriage is not the safe realm she believed it to be. Bertha's marriage does not save her from living as a prisoner despised by her own husband. While Rochester admittedly treats her kindly by the standards of the time (most husbands would have sent such a wife to an asylum, where inmates were often abused and neglected by the staff), his attitude towards Bertha still shocks Jane enough to make her wonder if she should expect the same fate should she ever lose her mental faculties.
Secondly, Jane realizes that staying with Rochester as a mistress would require her to occupy an unstable state socially, morally, and financially. She would have none of the protections that come with marriage and would be made absolutely dependent upon Rochester. As a result, Jane flees Thornfield, wandering through the wilderness and then spending time with (unbeknownst to her initially) her cousins at Moor House. During this time, Jane comes into her own: she teaches poor children, develops a relationship with family, and gains an inheritance from her dead uncle.
Though tempted to marry her cousin St. John Rivers despite not loving him romantically, she chooses to go back to Rochester, who is now humbled by financial loss and physical injury. Now that Jane and Rochester are on more equal footing, they are able to marry happily. In this way, Jane Eyre presents marriage as ideal for women who are self-possessed and in love with their chosen mates, rather than as a safety measure against loneliness or other challenges.