The first thing to note is that different people in different tradition, periods, and circumstances have a variety of reasons for turning to religion. Also, all religions are different. It`s unlikely that one could provide a single reason to account for the behaviour of billions of people over several thousand years.
In the case of the Abrahamic religions (Judaism, Christianity, Islam), one reason why people may become more focussed on religion during times of strife is that when life in the present world is unpleasant, people may become more concerned with the notion of an afterlife. Also, if the external world seems a place of senseless violence, one may become more concerned with ultimate meanings than if one`s external life is pleasant and untroubled.
Religion preached hope and salvation and teaches humans high moral values. Plus, it's really comforting to know that there's always a greater power that is taking care of you if you act nicely.
Terror and war are the two severest causes of distress for the individual, family and community, caused by violence. People turn to religion at times of distress.
Mainly three reasons: First, religion helps to keep up the hope for a better tomorrow, and second, helps to cope up with the mental agony. And third, it is in times of severest distress that our mind gets the philosophical desire to know the unknown. Religion is the subject that deals with the unknown and its relation with us.
Most people believe in an unvisible power. Its only one. On the other hand people remain involved in many objects and thus various thouhgts arise in mind. Mind becomes aware of death of the body. It frightens him. If the mind remains absorbed in one thing which hopes to give peace and shelter, a person, to some extent, feels secured. People lose beliefs in the perishable earth.
Almost all people learn that religion means a kind of blind belief in an unseen power/energy. We also learn that He blesses us and makes us secured.Science is related to lifeless matter. It experiments with it only. That is why some people call it sensate civilisation. Science has invented things only for our food, comfort, fear and to produce. But it has never sought to experiment with life. Mainly the religious books are related to it ans almost all philosophies talk about life. Therefore people take shelter with it.
Religion provides a direct known reference to solace and provides comfort as in the Christian aspect, In the Bible, Jesus the son of God who came to save mankind from eternal destruction, says "come to me and I will give you joy." Likewise people in suffering find that their faith in religion works. They therefore hold on and hope that God /Allah will releive them from the suffering.
It is also believed that the suffering is attributed to a cause and that there's a reason like the case of Job in the Bible who was mvery wealthy but the devil tested him by plagues and excessive losses of his property yet after Job remained focussed unto the Lord, his riches were repayed and doubled later.
Terror and repurcussions of war are attributed to evil. In Genesis the first book in the Bible, the creation story highlights that evil came and tempted Eve a woman God had made for man and thats when sin/evil and terror came into the world.