At the end of the TOS episode Bread and Circuses, Uhura pointed out at the end that the slaves on that planet were not Pagan "Sun" worshipers, but rather they were Christian-analogous followers of the "Son" of their god."God" exists in the Trek universe. It's always an alien being or computer disguised as "god", and it may or may not require a starship.
Of course, Uhura's line in that episode wasn't about of whether or not God exists, but instead it touched upon the faith of the people of that planet. That planet's "Son worshipers" faith in a son of god was a real part of their lives, even if it happens to turn out that their god is not real.
Most Star Treks that dealt with religion or God did so using this approach of not overtly attempting to answer the question of whether or not a supreme being exists. Instead, it attempted to look at it from the philosophical side of studying the idea of human (or alien) faith itself -- i.e., the "human" side of faith and/or religion.
Faith and religion are real things that exist in our world whether or not a supreme being exists. I think episodes that explore faith in a respectful manner are worthy of Star Trek inasmuch as it is an exploration of the Human Condition -- something that Star Trek has often excelled at.
Last edited: