The general consensus is that the third season of Star Trek: The Next Generation is when it hit its stride.
There is an episode in the third season that dealt with religion called Who Watches the Watchers. The basic plot is that some Federation anthropologists are observing humanoids whose technology is at the level of humans a few thousand years ago. But due to equipment failure, the anthropologists are discovered, and one is captured by the aliens. Then a few crew members go down, and one of them is captured.
At the beginning of the episode, the aliens seem atheistic. They regard beliefs in gods and spirits as superstitions of their ancestors. But as they encounter Starfleet’s advanced technology, the aliens think that the Enterprise crew are gods. By the end, the crew reveal themselves as nothing more than beings with more advanced technology, crew members are rescued, and the observations must come to an end.
Throughout the episode religion is regarded as superstition and magical thinking, and something that societies (and individuals) must outgrow. I got the impression from the Memory Alpha page for the episode that it is not a fan favorite. I like it a lot. I like episodes that tell a nice story for an hour and also touch on larger themes in culture and society.
There were a few good quotes about religion in the episode. Here are a few from the Memory Alpha page:
“Horrifying… Dr. Barron, your report describes how rational these people are. Millennia ago, they abandoned their belief in the supernatural. Now you are asking me to sabotage that achievement, to send them back into the dark ages of superstition and ignorance and fear? No!”
- – Picard
“Are you sure this is what he wants? That’s the problem with believing in a supreme being: trying to determine what he wants.”
- – Troi
Image from Memory Alpha, copyright owned by CBS, assumed allowed under Fair Use.