I would say that Eberron with its mystery about the true nature of the gods and allowing any alignment to be a follower of any god is closer to a model of realism and historical accuracy than Forgotten Realms active materially manifesting gods with (depending on edition) strong alignment restrictions for religions.
Religions doing enough evil would not be good in D&D alignment terms, the fact that they are worshiping neutral or good gods would not turn the evil actions not actually evil.
Doing some evil but significantly more good might be enough to still be good, but that is a judgment call.
FR seems to be a model of including historical inquisition type evil in a fantasy D&D western analogue.
Though I have personally taken an Eberron-like approach* (and that setting was absolutely one of my inspirations for doing so), it's completely possible to have legitimately good religions worshipping legitimately good entities which still, nonetheless, go wrong and do evil things.
4e had some
truly excellent work on this front. I'm specifically thinking of a 4e era Dragon article that spoke of Bahamut. It goes into depth on how even Bahamut's clear, concise, straightforward doctrines could be twisted into something evil if misunderstood or misapplied, and that because he isn't omniscient and isn't omnipresent, he cannot always be perfectly policing the behavior of every sect or branch of his church. He tries to pick good people, but the church is made of mortals with fallible judgment, and even Bahamut himself is not totally free from error. As Gandalf said to Frodo, “Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends.” Bahamut IS very wise, but he's not necessarily wise enough to see all ends.
That doctrine, by the way, is as follows:
- Uphold the highest ideals of honor and justice.
- Be constantly vigilant against evil and oppose it on all fronts.
- Protect the weak, liberate the oppressed, and defend just order.
Sounds pretty good, right? How could you mess up those? Answer: much more easily than one might think. "Uphold the highest ideals of honor and justice" can very quickly become "punish all crimes or even minor misdeeds with unremitting harshness, for only the absolutely pure and untainted can truly uphold the
highest ideals of honor and justice" (ignoring Bahamut's merciful nature and becoming a Lawful Stupid Moral Policeman). "Be constantly vigilant against evil and oppose it on all fronts" sounds lovely until you remember that that exact thing is what drove the IRL Inquisition and the witch hunts despite it being
explicitly official Catholic doctrine that witches didn't exist and believing they did was heresy. Constant vigilance is always at risk of becoming inescapable paranoia. And that last three-way command is chock full of abusable phrases. "Protect the weak" can become "force the strong to convert, and destroy them if they refuse, because you cannot trust the strong not to prey on the weak unless they follow Bahamut." "Liberate the oppressed" depends pretty heavily on how you define what "oppressed" means (and the article gives an example of some Bahamut-following knights invading a land ruled by druids because obviously the druids must be oppressing them in order to stay in power!) And "defend just order" can fall down at the very thing it's trying to prevent, namely, people not being able to correctly identify which side (if any) in a conflict is the just one. I believe the example given is the loyal knights of a kingdom obeying the commands of the tyrannical princess because she IS legally the rightful ruler, because they don't know or realize just how bad she's being, and thus treat the resistance against her rule as people trying to destroy "just order."
So...yeah. Even with legitimately good deities who promulgate legitimately good doctrine and who have followers generally desiring to do good to and for others, it is still 100% possible to have branches or sects that go astray and potentially even become outright villains. Human imperfections are like that, sadly.
*In the setting of Jewel of the Desert, it has been established that it is not possible to objectively answer whether the One is truly who They claim to be. Not even They personally can prove it beyond all possible doubt, because no magic or technology that does not come from them can look back to see the truth with absolute, unquestionable clarity, and if the tool used was created by the One, how can one be totally sure that it wasn't created with bias? Ultimately, each person has to decide for themselves what evidence or testimony they believe accurately describes existence. Plus, the One has Their own reasons for being content that true, unequivocal proof of Their divinity is impossible (in brief, They would not want to prove it beyond any doubt even if they could, as that could be coercive, and coercing mortals would defeat the purpose of creation in the first place.) Note that this has NOT prevented the Safiqi priesthood from occasionally doing nasty things. Their moderate wing is the one in power right now, but the hardcore orthodox wing has had control before and has ordered forced conversions and even effectively "holy war" against non-believers in the past. Such things NEVER turn out well though, which results in the hardliners falling out of favor sooner or later. Safiqi magic cannot truly pacify the spirits of the unquiet dead, only Kahina magic can do that. Thus eventually they are forced to turn to the main group they would persecute in order to save their flocks, and that forced eating of humble pie tends to dampen enthusiasm for such rabid dogmatism. But incidents that inflame tensions can always crop up and give new fuel to their fire as well, so the flame never completely goes out.