Biology matters, and it seems to me a reasonable claim that the link between irreligiosity and bad behavior is due to impulsivity. An impulsive person, for example, is more likely to get into trouble with the law and will probably not enjoy a boring sermon in church.
The MIDUS Study measured self-control versus impulsivity with an index and also asked if the respondent had ever been in jail. First, I estimate the effect of religiosity alone, and then along with impulsivity in order to see how much impulsivity shrinks the religiosity--jail link. Here are the logistic regression coefficients:
Logistic regression coefficients (sample size = 2,119, whites only)
Church attendance -.35*
Church attendance -.33*
Impulsivity does raise the risk of jail, but it only reduces the impact of religiosity a little bit.