“I talk about the gods, I an atheist.”
-Ursula K. Le Guin (Introduction to The Left Hand of Darkness)
The subject of religion is, easily, one of the thorniest and most problematic elements of worldbuilding. This is, of course, especially true of primary world settings. It is easier with secondary worlds, if only because the audience is not invested in quite the same way or to the same degree.
Depending on one’s perspective, religion shapes or is shaped by society, or both. This relationship can be quite useful for explaining myriad things as well—from laws to treatment of non-humans to treatment of magic. That said, I commonly think of seven elements when I’m considering religion in worldbuilding, placed in two groups for ease:
1) No Religions
2) Ignore Religion
3) One Faith
4) Multiple Faiths
If there are religions and they are not being ignored:
Religion has been used quite well in fantasy, particularly the work of George R.R. Martin (A Song of Fire and Ice series), Steven Brust (Vlad Taltos series), and Rick Riordan (both Percy Jackson series and the Kane Chronicles) stand out amongst modern authors. Michael Moorcock’s Eternal Champion series, particularly the Elric volumes, display an interesting take as well. And, of course, neither Tolkien nor C.S. Lewis can be left out, even if the former’s use of religion is heavily downplayed, and virtually invisible, until The Silmarillion.
Religion can be ignored effectively as well. Depending on the author, religion could be non-existent or assumed to exist, but not important for the story. C.J. Cherryh (mostly, except the Fortress series) and J.K. Rowling are good examples here.
If religions exist, though, more questions beyond the number of deities arise. First and foremost is: Do the deities actually exist, or are they figments of the religions’ collective imaginations? If the latter, how does the clergy maintain authority (historically, religions have used economic and political power, the technology of writing, and claiming responsibility for nature).
If the god(s) exist(s), then what is the nature of divinity? Steven Brust describes divinity as another state of being (all the gods are ex-mortals). Michael Scott (The Secrets of the Immortal Nicholas Flamel) sets the gods up as another, older, species. Roger Zelazny describes the gods as aliens in Creatures of Light and Darkness (not an uncommon method). Rick Riordan is not entirely clear on the gods’ nature (or it could vary by culture) in that the Greco-Roman gods seem to have a physical existence on Earth (enough that they can sire or bear demi-god children), but the Egyptian gods appear to be powerful spirits, capable of acting on Earth only by possessing human avatars.
There are also, of course, questions for the clergy. Immediately, what do the clerics wear, both daily and for ceremonial purposes? What role do the clergy play in the faith, and in the greater society? What rules, if any, must the clergy follow (secular, within the hierarchy, and divine)? Based on their role in society, do they follow a different temporal legal code or have special courts (historically, the Church’s priests had both in Europe)? For pantheons: do clergy serve specific deities (one each; a common fantasy decision) or do they serve the pantheon as a whole?
And that’s just scratching the surface.
For a very systematic method of creating fictional religions, I highly recommend SJGames’ GURPS: Religion, which covers a great amount of detail and offers some examples, both historical and fictional (and requires no knowledge of the RPG system to be useful).