The answer to your question can be found in chapter V, titled "Hester at Her Needle".
Hester Prynne certainly could have avoided a lot of problems by simply leaving the village. However, as Hawthorne writes:
Her sin, her ignominy, were the roots which she had struck into the soil.
What these words entail is that her actions, and the consequences of them, have changed Hester so tremendously that she basically was reborn again into another woman. Although this woman has less than an ideal life, it is life nevertheless and Hester felt a moral responsibility to embrace it and live with it. Therefore, that first reason can be attributed to moral responsibility to abide by whatever comes her way.
The second reason is Dimmesdale.
another feeling kept her within the scene [...] one with whom she deemed herself connected in a union, that, unrecognized on earth, would bring them together before the bar of final judgment...
Even after the humiliation, the loneliness, and the terrible treatment that Hester has endured from the villagers and the aldermen alike, the fact remains that Hester not only feels love for Dimmesdale, but also a spiritual connection that keeps her bound to him. It is almost unbelievable to the modern reader that Hester would harbor any love inside of her for the man that has left her to suffer in silence for actions committed by the two of them. Moreover, that this man is faking his righteousness and still acts like a man of God makes her connection to him all the more awkward. However, those are exactly the reasons why Hester decides to continue a sad life in the village facing society head on.