Benjamin Franklin's feelings on God and religion were complicated. While it's true that Franklin believed in God and saw great benefit in religion, he himself (as I've written before) had an aversion to church services (or at least services led by dull pastors).
Like many people, Franklin's own views on faith and religion changed throughout his life, both ebbing and flowing during various stages. Born in the Calvinist tradition, Franklin's belief in the inerrancy of Scripture faded as he began to read deist writers such as Hume and, later, Rousseau. But Franklin's view that a higher power existed remained unwavering (from what we can glean), as did his belief that religion played a vital role in creating moral citizens.
Nowhere, perhaps, are these beliefs more evident than in a 1757 letter Franklin sent to an atheist friend, identified as "Mr. J.H." (It's unclear who Mr. J.H. was. Historians had long presumed Thomas Paine was the recipient, but both the date and the initials cast doubt on this claim.)
In the letter, Franklin scolds his acquaintance for dismissing religion as unnecessary in a text he was preparing to publish.
I have read your Manuscrit with some Attention. By the Arguments it contains against the Doctrine of a particular Providence, tho’ you allow a general Providence, you strike at the Foundation of all Religion: For without the Belief of a Providence that takes Cognizance of, guards and guides and may favour particular Persons, there is no Motive to Worship a Deity, to fear its Displeasure, or to pray for its Protection. I will not enter into any Discussion of your Principles, tho’ you seem to desire it.
Readers will notice that Franklin did not question the character of his friend, despite J.H.'s alleged desire to have Franklin do so. Instead, Franklin made a pair of utilitarian arguments: 1) J.H. was unlikely to succeed in changing minds but would likely draw much "odium" upon himself; and 2) If J.H. was successful, the consequences would be bad.
At present I shall only give you my Opinion that tho’ your Reasonings are subtle, and may prevail with some Readers, you will not succeed so as to change the general Sentiments of Mankind on that Subject, and the Consequence of printing this Piece will be a great deal of Odium drawn upon your self, Mischief to you and no Benefit to others. He that spits against the Wind, spits in his own Face. But were you to succeed, do you imagine any Good would be done by it? You yourself may find it easy to live a virtuous Life without the Assistance afforded by Religion; you having a clear Perception of the Advantages of Virtue and the Disadvantages of Vice, and possessing a Strength of Resolution sufficient to enable you to resist common Temptations. But think how great a Proportion of Mankind consists of weak and ignorant Men and Women, and of inexperienc’d and inconsiderate Youth of both Sexes, who have need of the Motives of Religion to restrain them from Vice, to support their Virtue, and retain them in the Practice of it till it becomes habitual, which is the great Point for its Security; And perhaps you are indebted to her originally that is to your Religious Education, for the Habits of Virtue upon which you now justly value yourself. You might easily display your excellent Talents of reasoning on a less hazardous Subject, and thereby obtain Rank with our most distinguish’d Authors. For among us, it is not necessary, as among the Hottentots that a Youth to be receiv’d into the Company of Men, should prove his Manhood by beating his Mother.
Franklin concluded his letter with this advice:
I would advise you therefore not to attempt unchaining the Tyger, but to burn this Piece before it is seen by any other Person, whereby you will save yourself a great deal of Mortification from the Enemies it may raise against you, and perhaps a good deal of Regret and Repentance. If Men are so wicked as we now see them with Religion what would they be if without it? I intend this Letter itself as a Proof of my Friendship and therefore add no Professions of it, but subscribe simply Yours
The pragmatic argument Franklin used to defend religion was not unique. It was posited by thinkers as early as Socraters (see his conversation with Meno, recorded by Plato); it was later honed by the philosopher William James (see James' essay "The Will to Believe" for an overview).
At risk of offending the spirits of messieurs Franklin, James, and Socrates, I must say: I've always found the pragmatic defense of religion terribly weak. For one, the words "good" and "bad" are highly elastic terms likely to change depending one's religious/philosophical viewpoints. (The Christian burning a witch, the Aztec sacrificing a child, and the Jihadist beheading the infidel all believed in the sanctity of their actions, I suspect. So there's reason to believe we might disagree on what ideas would build a "good" society.) Second, and more importantly, there is something odd and potentially pernicious in classifying an idea as true and good because the outcome derived is a desirable one.
If religion (of any kind) is true only because it is more likely to make man a creature more amenable to some particular person's idea of virtue, and thus create a better and more civilized society, I'll pass. And I'll close by adding this: philosophy that ties truth not to the external order of things but to the fruit it might bear is a Pandora's box.