Some say it's because science disproves God or that science and religion are somehow incompatible. Others point out that most were atheists before they ever became scientists, suggesting they pursue science because of their atheism. Both explanations assume a false dichotomy. The true answer probably is very complex, but two factors might explain a lot of it: demographics and personality.
Personality may explain even more. The Myers-Briggs Type Indicator (MBTI) is probably the most common measure of personality. Though it has several major flaws, it has been used and studied enough to provide useful statistics.
The MBTI type typically associated with scientists is INTJ, whose description closely resembles the stereotypical scientist. Hence, it often is called the "Scientist" type. INTJs generally are analytical, opinionated, and don't believe things without "cold hard facts" -- a common description of atheists as well. In a survey of 10,627 American atheists, 13.7% were classified as INTJ, compared to only 2.6% of the general population.
A few other personality types are typically associated with scientists. By far the most common of these is ISTJ, which tend to prefer more practical, applied science than their INTJ cousins. For example, ISTJ has been found to be the most common type among National Weather Service employees. It's also the most common type among atheists. 41.2% of atheists are ISTJ, but only 13.8% of the general population are ISTJ. Thus, a majority (54.9%) of atheists are either ISTJ or INTJ, compared to only 16.5% of the general population.
Personality type can explain the high male-to-female ratio among atheists [and perhaps scientists as well]. Male and female atheists have similar proportions of ISTJ and INTJ (40.8% and 11.7% for female atheists, 41.4% and 14.4% for male atheists). But in the general population these two types are approximately 70% male -- just like atheists and scientists!
Combining demographic and personality data, we can calculate the probability that a random person is an atheist, given basic demographics. For example, starting with a prior probability of 2.0% (the % of atheists in the general population), the probability that a random white male would be an atheist is 3.5%. If the random white male is an INTJ, that probability increases to 14.5%. If we consider random college graduates, it becomes 21.1%.
Extending the calculations to a random group of college graduates (and post-graduates, in parentheses) with the same race and gender makeup as scientists [72% male, 69% white, 18% Asian, etc.], the following percentages are expected to identify as atheist:
- INTJ: 20.2% (23.7%)
- ISTJ: 11.4% (13.7%)
- INTP: 7.4% (9.0%)
- ENTJ: 6.0% (7.3%)
- INFJ: 5.5% (6.7%)
- ISTP: 4.6% (5.6%)
- ESTJ: 3.6% (4.4%)
- ENTP: 2.8% (3.4%)
- ESTP: 2.0% (2.5%)
- INFP: 1.7% (2.1%)
- ENFJ: 1.5% (1.9%)
- ISFJ: 1.5% (1.8%)
- ISFP: 0.6% (0.8%)
- ENFP: 0.6% (0.7%)
- ESFJ: 0.4% (0.5%)
- ESFP: 0.3% (0.4%)
Thus, if scientists are predominantly INTJ and ISTJ, the 17% who are atheists is similar to that what would be expected from a random sample of people with those personality types and similar basic demographics.
Of course, there are much deeper factors than what these crude statistics represent. Scientists are quite diverse in ways that aren't accounted for here. Not all are INTJ or ISTJ, including myself (an INFJ), and I couldn't find any statistics about that. Correlation doesn't imply causation, and these variables probably aren't completely independent as the equations assume. However, unlike the "science and religion are incompatible" explanation, this one at least has some science to support it.