Although it's impossible to be sure, I think they fear that somehow Hester's behavior would become normative. After all, isn't that one of the basic purposes of all punishment, to set an example for others so that the behavior does not become acceptable? It is interesting that, at the beginning of the book, it is the old biddies in the town who are loudest in their denunciations of Hester; the younger woman, perhaps because she is more likely to "sin" as Hester did, is much more sympathetic and forgiving. And as the story progress, it seems that everyone is willing to forgive Hester as she becomes the "Angel" or "Able" one.
I suspect they most want the father of the child named for the same reason. His punishment, perhaps alonside of that of Hester, would have sent a clear message to the townspeople that this behavior would not be tolerated in a "godly" town like Boston. It is interesting that, excepting Chillingworth, of course, the people seem to lose interest in discovering the father's identity as they get on with their lives. Maybe the will to punish is short lived ....
The villagers want Hester Prynne to be punished for her crime of adultery, but more than that, they want her to name her lover. She refuses to identify the father of her child. She is courageous in accepting full responsibility for the child.
They believe that he must also be punished. For the Puritans, God was a harsh judge, so therefore, they were required to judge in God's name on earth.
"In religious terms it saw God not as a distant and harsh authority,"
"On the scaffold, Boston's highest clergyman, John Wilson, and Hester's own pastor, Rev Dimmesdale, each ask her to reveal the name of her partner in crime."
"Reverend Dimmesdale makes a particularly powerful address, urging her not to tempt the man to lead a life of sinful hypocrisy by leaving his identity unnamed. Hester refuses."
The Puritans feared sin. They believed that a sinner within the community condemned them all.
"The Puritans required a strict moral regulation; anyone in the community who sinned threatened not only their soul, but the very possibility of civil and religious perfection in America and in England."