It really goes back to the Donatist controversy in the 3rd century and to Augustine who argued that the church must expect to be made up of a "mixed body" of saints and sinners, refusing to weed out those who had become lapsed, defiled. He taught that the validity of the church's mission did not depend upon the holiness of its clerics or ministers (some argue, the sex or orientation of the cleric, too), but upon the person of Jesus Christ. Of course, if the cleric committed a crime, he or she like any citizen should be sent to prison (and seek forgiveness there) while making restitution and doing time. And in Chapter 25 (Matthew), Jesus reminds us how important it is to "visit those in prison," but, at the same time, not let them out (implying that criminals should not be released until their sentence is up).