Why is Hester not executed for her crime?
Hester is not executed for committing the crime of adultery because her community cannot actually know if she has committed this crime. She has been in the colony for about two years, and though her husband was supposed to follow her shortly after she arrived, he never showed up. He is believed to have perished when his ship wrecked, but because his body was never found, no one knows for sure if he is dead. Thus, Hester exists in a sort of limbo: she does not know if her husband is alive or dead, and so she cannot remarry (in case he is still alive). When she becomes pregnant, the community knows that the child she carries cannot be her husband's, since she's been alone in the colony for too long for that to be possible, but they don't know if her husband is dead, and -- if he isn't dead -- she hasn't committed adultery. So, they come up with a sort of compromise punishment in order to deal with her.
It is true that in those days a person could be executed for committing adultery. But instead, Hester gets "only" a prison sentence and the scarlet letter. The major reason for this is that the court believes that there are circumstances that reduce her level of guilt.
Specifically, they decide that her husband's absence makes a big difference. It's not like she had her husband right there at home and went out and cheated on him. Instead, her husband was off somewhere and might have been dead for all she knew. So because of that, the court lets her off "easy."