The primary attraction is based on animal instincts.
We evolved as animals living in groups. Groups provide a sense of security and protection. Good standign in a group insured the likelihood of attracting a mate and reproducing.
Humans are social animals.
Religion provides a sense of community, which humans tend to be drawn to instinctually, because at one time, not so long ago in our evolutionary past, it meant survival.
Today religion still provides a sense of community, and a person's standing in that community still feels important to them for instinctual reasons, not rational reasons. We are a product of our evolutionary past and retain a lot of the instincts and behaviors from that past.
Instinct usually manifest as emotions in modern humans.
Humans are still evolving, and it may be that not all behaviors will prove beneficial for survival, but it will take a very long time for any noticeable changes to take place, but for people of that tiem period it wont' really be noticeable at all.
Humans forget almost all the time that they are animals and a product of their evolutionary past. They see modern humans as an end result, not an ongoing process of evolution.