I think that modern religions and the way they learn to part with certain medieval ways is critical. The Jewish religion has been arguably successful with this, producing exceedingly prestigious scientists and mathematicians. The risk is always the "fundamental" factions.
Their genetics and their environment did, to varying degrees, but religion is only one small aspect of the latter.
What's your basis to assert that it is the most important factor?