This is a quote from the Book of Tobit, which is recognized as part of the deuterocanon by the Catholic, Eastern Orthodox, and Oriental Orthodox churches. The book tells of a father, Tobit, and his son, Tobias or Tobiah. Tobias is led by the angel Raphael to find a wife, and returns with medicine to cure his father's blindness. As Raphael prepares to go, he reveals that he is an angel, but before he does so, he gives them advice, including this sentence:
Do good, and evil will not overtake you.
Tobit 12:7b (New American Bible, Revised Edition)
Arthur Miller was Jewish, and the Book of Tobit may have been familiar to him, though it is not in the current Jewish canon. Puritans may also have been familiar with the book, though they follow the common 66-book Old Testament canon used by most Protestants.