The fact that Mary is pregnant has two influences on the story. One is directed at the reader and the other is a direct influence of Mary's actions.
Mary's pregnancy influences the reader by making the reader sympathetic to her and her actions. She is a soon to be mother, which is going to be a ton of work. According to my wife, being pregnant is no walk in the park either. So the fact that she is pregnant immediately causes the reader to want to protect her. Those protective feelings continue to grow after Patrick announces that he is leaving her. We care for Mary, not Patrick.
Mary's pregnancy also influences her actions. I think that Mary would have confessed to her actions and taken whatever punishment was given to her, if she was not pregnant. The text indicates that she knows what her punishment will likely be, and that it would be a relief. She doesn't know what will happen to her unborn child though, and that fear motivates her to find a way to get away with her crime. She's not willing to risk the baby's life for her crime.
As the wife of a detective, she knew what the punishment would be. It made no difference to her. In fact, it would be a relief. On the other hand, what about the baby? What were the laws about murderers with unborn children? Did they kill them both -- mother and child? Did they wait until the baby was born? What did they do? Mary Maloney didn't know and she wasn't prepared to take a chance.