It can play a role but there are so many other factors. Some people turn to theism to cope with hardships which means they are less unhappy thanks to it. But on the other hand there are people who live a restricted frustrating childhood in a religious family and finally experience freedom with atheism.
It’s more interesting to ask ourselves what precisely religion brings to the table, the negative and the positive, so we can answer difficult political questions in relation to religions