Why did Hester go to Governor Bellingham's mansion?
As previously explained in chapter 5, "Hester at her Needle," the woman was quite versed and extravagant in the art of embroidery. She had sewn and made garments for the most important people of the village. In chapter 7, "The Governor's Hall," Hester goes to the mantion because of two things. First, because she has to bring to the governor a pair of gloves that she had made for him. Second, because she has heard a rumor that the magistrates want to take Pearl from her custody. Therefore, Hester had to confront the magistrates and ask them about this whole thing.
It had reached her ears that there was a design [...] to deprive her of her child. On the supposition that Pearl, as already hinted, was of demon origin, these good people not unreasonably argued that a Christian interest in the mother's soul required them to remove such a stumbling-block from her path.
Puritans believed that any child born in a way that does not go in agreement with the tenets of their faith cannot be a child of God. Since the soul of such child had to be saved, it was imperative to remove the child from their equally ungodly mother.
Hester also goes there because she knows that Dimmesdale would be there and could speak on her behalf. Hester sees that Dimmesdale is basically standing there witnessing her battle with the Governor and she finally yells to the point of screaming that Dimmesdale speaks for her and sees that it is resolved that Pearl will not leave her. In the end, Dimmesdale does speak on her behalf as her pastor, and convinces the men not to take the girl away.