Going around in circles, you have a lot of time to think.
I used to be a materialist, but it was so depressing. If there really is no "purpose" to it all, then what's the point? Why bother with anything?
Eventually you have to "value" something, and the moment you do, you have introduced "meaning" into the universe. Meaning, of course, can't be measured, so now we are forced to admit that the immaterial must exist.
So then we stumble into religion, and the restrictions and commandments fall on our heads like a cold rain. But rather than rebel against religion, discarding it because of the artificial constraints it puts on our lives, we should view it as spiritual exercise.
Suppose, for example, we wanted to learn a martial art. Would we simply start flailing away, imagining that any wild movement we make would be an effective strike against an opponent, or capable defense? No! We would willingly submit to the training of a master, using self-discipline to repeatedly practice moves and stances whose uses we would not really know.
Religion is the practice we subject ourselves to, so that we may learn the art of spirituality.