For centuries, science and religion have been seen as rivals, but their relationship is more complex than it seems.