Religion is not an instinct. Not on the individual level, and not on the societal level, where there is only a manifestation of principles of conformity.
Optimism and sociability are intelligible enough. There is no need to introduce magical properties except to bamboozle the credulous.