I think it's good to ridicule religion.
Ridicule is complicated from a utilitarian perspective. By design, ridicule is immediately harmful: it makes its target feel bad. So, in a consequentialist utilitarian framework, we can justify ridicule only by concluding first that we can know, directly or indirectly, that the overall effects of ridicule promote more happiness and less suffering in the long run to offset the immediate suffering. Second, we have to know that there is no alternative means that is less immediately harmful.
The idea of doing something bad in the short run for a good in the long run is incredibly problematic. We have a lot more knowledge about the short run than we do about the long run. That's the whole point of ethical principles: ethical principles encapsulate our social knowledge (as well as social prejudice, confusion, ignorance, and delusion) about the expected long run effects of short run actions. I strongly suspect that, for instance, people don't like flipping the switch in the Trolley Problem* precisely because we are socially conditioned that uncertainty** about the indirect and long term effects prohibit actively killing a person. We also must consider the meta-problem: when we justify doing a short-run harm for a long-run good, we have to also ask: who will be making those decisions, under what constraints, and to fulfill which ends? But saying that causing immediate, local harm now for a long-run, global good is problematic is not to say that it cannot possibly be justified.
*See also Can Bad Men Make Good Brains do Bad Things?
**The assumption of certainty made in the presentation of the problem just doesn't help: our intuition about the world is both unconscious and deeply conditioned (usually) about how the world actually is; it's difficult or impossible for us to consciously adjust our intuition to conform to alternative physics. It's hard enough to adjust our intuition to true but non-obvious physics.
The justification for ridicule, then, must address what the long-run effects of ridicule will be, how we know what those effects are, whether they outweigh the short-run harm, whether less harmful methods exist, and how we socially decide whom to ridicule and when. I think we can justify ridiculing religion on these grounds.
The expected long-term effects of ridicule are change of behavior. When we ridicule some people, or actions, or ideas, we are saying that these people, or people who do or think these things should change. Hence, ridiculing people for unchangeable characteristics — race, sex, gender, sexual orientation, height, and, to some extent weight — cannot effect any long-term change in behavior; therefore, the immediate harm cannot be outweighed by the impossible to achieve long-term effects. If you ridicule someone for being Black, you're just being mean.
Second, since individuals are the best judge of what is harmful, it doesn't make sense to ridicule people only for harming themselves. Even if fat people could change their weight (and there's a lot of science that shows that losing weight is incredibly difficult, and often impossible), they harm no one but themselves. Presumably, they are rational people, and have decided that even if losing weight were possible for them, the short-term pain outweighs the long-term benefits, and they, not I, are the experts on their own utility functions.
However, we can reasonably expect long-term positive effects of ridiculing religion. We want people to stop using religion to hurt other people. We know how religion harms people: people use religion to justify and perpetuate sexism, misogyny, racism, homophobia, national chauvinism, and a host of other obvious ills. We know that people use religion to perpetuate subordination, exploitation, and in some cases outright victimization. And we know that the underlying justification — some people know what God wants, and what God wants overrides anything that mere human beings might want — is utterly without merit.
(I want to take a brief sidebar and address the argument: I'm (this or that religion), and I don't think that God wants us to be sexist, racist, exploitative, etc. The fundamental problem with religion is not content but methodology. You don't know any better than the sexists, racists, etc. about what God does or does not want. You have to appeal either to personal revelation or to scripture. If you appeal to revelation, then the charisma and rhetorical skill of those who claim revelation becomes more ethically persuasive than the content of the revelation. If you appeal to scripture, then, well, scripture is equivocal enough that it's certainly possible to read most anything into it, but you're still relying on the charisma and rhetoric of the interpreter, rather than the content of the interpretation, for ethical persuasion. If you want to argue on the basis of content, then you don't need God in the first place: we can just look at the content directly.)
We won't stop all sexism, misogyny, racism, etc. ad nauseam by convincing people to stop being religious (or just stop being such assholes about their religion), but I think we could put a real dent in these social ills. And whatever positive effects religion might have, if we can tell that that effects are positive without appeal to religion, then we can find non-religious ways of gaining the effects.
We also have to look at the potential negative effects. First, ridicule might be ineffective. Ridicule often enough is effective, but it's not always effective. But the immediate short-run effects are relatively small: some people have their feelings hurt. Just having a small negative effect is not a justification by itself — a small harm is still a harm — but it does say that the risk of ineffectuality is relatively low.
More importantly, when individuals of a particular religion are generally subjugated in some context, ridicule can perpetuate and justify that subjugation. For example, one argument against Charlie Hebdo is that because Muslims are generally subjugated in France, ridiculing Islam perpetuates and justifies that subjugation. This argument has some merit but I think there are some good counter-arguments.
First, Muslims in France are not subjugated because they are Muslims (much less because Charlie Hebdo ridiculed them). I'm no expert in French sociology, but as a communist, I tend to see the underlying cause of subjugation and exploitation as capitalism, not religion. If Muslims really are subjugated in France, it's because capitalism requires that somebody be subjugated, and the Muslims (perhaps among others) just got the shitty end of the stick: if it weren't the Muslims, then it would be someone else. I obviously don't think that people should be subjugated because of their religion (or race, or gender, or any other ineluctable characteristic), but I also don't think that we should distribute subjugation "fairly": we shouldn't subjugate anyone.
But not everyone believes that capitalism is the underlying problem, or that capitalism requires subjugation, or that subjugation is necessarily bad. I would disagree with the position overall, but I do think the argument has at least some merit that the subjugation of Muslims in French society is at least in part due to their resistance to assimilation. Just being religious, just going to the Mosque on Friday instead of Church on Sunday (or no Church at all), is no barrier to assimilation, but insisting on private standards of justice, such as the permission of the subjugation of women, or restrictions on others' free speech, can be barriers to assimilation.
The position of Muslim immigrants to France is very different from the position of Black people in the United States: Black Americans were forcibly brought to the United States and forced into literal chattel slavery (along with genocide and wars of aggression, one of the Unforgivable Curses). Their presence in the United States is 100% the result of and the responsibility of White Americans. Black Americans have zero duty to "assimilate" to a culture that forced their inclusion; White Americans have at the very least (and we have a lot more duties) a duty to simply take Black Americans as they are, and change ourselves to include them fully in American society. In contrast, Muslim immigrants to France came there, presumably, because they thought French society was better than their original society. And French colonialism was not slavery; decolonization is obviously justified, but non-assimilative immigration seems more difficult to justify.
Assimilation and acculturation are obviously complicated issues: immigrants, by virtue of acceptance into a culture, are entitled to participate in the social construction and evolution of that culture. But, frankly, ridicule (on both sides) is a part of the process of social construction. Even native-born members of a culture have a duty of enculturation; as a native-born White American, I cannot simply say that I am who I am, and everyone else has to unconditionally adjust around me. And if were I try to say that, I would subject myself to ridicule.
The point is: Unlike Black Americans, French Muslims did not start out as completely powerless. They chose to came (and the French chose to accept them), so they are part of the process. Immigrants have the right to argue, by any appropriate and effective means, for whatever cultural change they want; unlike White Americans, the French also have the right to argue back. They should avoid perpetuating subjugation, but unless Muslims were almost completely powerless, just because they are exploited to some extent in France does not mean they are immune to criticism. And if ridicule is legitimately part of that argument back, that criticism, then so be it.
(In contrast, the only "argument" White Americans have is, "I'm sorry. What happened to you and what is happening now is completely inexcusable. I can't change the past, but I will do today whatever you think is reasonable or moderate to fix the problem.")
We next have to ask: is there a better alternative to ridicule? Obviously, rational persuasion is always better. But rational persuasion is singularly ineffective when it comes to changing most people's religious beliefs. (Rational persuasion does work on some individuals, and in general having a rational basis for any position is valuable.) When rational persuasion fails to correct harmful behavior, we must resort to stronger measures. I am not a lets-hold-hands-and-sing-Kumbaya mushy liberal; I will not give up just because a harm requires stronger methods to correct. I think ridicule is a stronger method than rational persuasion, but it is milder than outright coercion. The most puerile, immature, scatalogical, and even misguided ridicule might sting, but I'll take it any day over the policeman's baton or the soldier's bayonet. Furthermore, a lot of religious people are just as offended, have their feelings just as hurt, just by people saying they disagree with them, much less offering rational criticism. So I think that the harm done by ridicule is often no worse than rational criticism, and substantially less worse than outright violent coercion. And ridicule is very different from, and less bad than, threats, harassment, or near-incitement.
Finally, we socialize ridicule by letting anyone do it. Ridiculing other people is a right, not a privilege. It's not even a privilege of the rich; it doesn't take that much wealth to print a magazine, and almost no wealth to ridicule people on the internet. No one, I think, can legitimately argue that unlike, for example, the Koch brothers, Charlie Hebdo used their immense wealth to magnify the impact of their speech; before the attacks, the magazine had been flying six inches from the ground for years, with a circulation in the tens of thousands (compared to the ~64 million just in Metropolitan France). I'm not saying that White (or non-Muslim) privilege is non-existent, but it's hard to tie any kind of privilege to Charlie Hebdo. (If France had actually tried to shut down any satirical publications because they were Islamic, that might be different, but I've seen no evidence of that. Even then, the response would not be to condemn Charlie Hebdo for using its privilege, but to condemn the French for creating the privilege.)
We can always argue that some instance of ridicule is misguided, mistaken, unwarranted, or otherwise defective. But we can always argue that any position, expressed in any form, from a scientific paper to a casual remark, is somehow defective. It is never wrong to criticize any speech for its content. But if we disapprove of ridicule itself just because it hurts people's feelings, then to be consistent, I think we have to disapprove of a lot of things, like criticism and simple disagreement, that also hurt people's feelings. If we want to disapprove of specific kinds of ridicule, then we have to justify why those specific kinds of ridicule are wrong, but not others.
I have not yet seen a compelling argument that the Charlie Hebdo cartoonists did anything more wrong than does anyone else who expresses strong opinions about socially important issues. They made some mistakes — as does everyone — and may have missed their intended targets — as does everyone — but I think they both intended to and actually were making the world a better place. Their deaths are not just an offense against the general prohibition against killing, but a real loss for the world.