This is often used as evidence for why the United States is more religious than Western Europe, on average.
Not specific to the first world war,but the classic cliche "there is no such thing as an atheist in a foxhole" would suggest otherwise The science there gets tricky, as some studies point one way, others the opposite, and none answer your question at all
We're not looking at cliches or specific studies here, and unfortunately I can't remember off the top of my head reading much concerning religion in interwar Europe, but I can talk about pessimism post World War Two. I'll be looking specifically at literature to exhibit the feelings and emotions of different authors and poets. This does not directly answer your question, and is by no means definitive, only granting weight to the opinions of certain people here.
I'll first start with Ernst Jünger, a viciously pro-military, questionably fascist writer, and veteran of the First World War. Writer of novels such as In Stahlgewittern (Storm of Steel), Das Wäldchen 125 (Copse 125), and Gläserne Bienen (Glass Bees), the former two were written 1920 and 1922, respectively, and were both about the First World War. In Stahlgewittern's original edition, it was more or less Jünger's wartime journal, describing his moments and battles, incredibly graphically at times. He revised it in 1924, showing an incredibly nationalistic and pro-war vision. Das Wäldchen 125 is another pro-war, nationalistic novel that glorified war and the accomplishments that come from it, they could be described as romanticizing war, but saying so would discount his actual wartime experiences. That message was completely different in Gläserne Bienen, published in 1957. In the aftermath of World War Two, his views completely changed. A central conflict in Gläserne Bienen is how there is no glory in war, how there is no room for individual achievements. I can't remember the exact quotes, and have unfortunately lost both my German and English copies of the book in moves at one point or another, but one that stands in memory are him talking about times that intense military training was defeated by technology control. Something along the lines of "One youth sitting a thousand miles away can cause more devastation in one motion than Frederick the Great during his entire Silesian campaigns." his views on life after the war were exhibited in the books as well, as it centers around Richard's search for meaning, duty, and a life after he is rendered obsolete by how war has changed.
There is also the work of Arno Schmidt. I'll be light here, but he was drafted into the Wehrmacht, and volunteered for frontline artillery service in order to get some leave to see home and arrange for his wife to stay in the west (they were from Silesia), so they would avoid the Red Army. He found no pleasure in society anymore, and this is especially clear in two of his works from the early 1950s: Brand's Haide (Brand's Heath), which takes place in a fictional postwar society much more chaotic than ours, and the narrator is trying to forge society back with other survivors without all the history and inheritance that the real world affords, exhibiting the impossibility of human society. Another, Schwarze Spiegel (Dark Mirrors) is a post-apocalyptic tale where the narrator begins terrified that he's the last person on earth, then (mild spoiler) he finds another, is at first releived, but then realizes just how terrible it is to be with other people. Romanticism had no room in his life, nor did any glimpse of a sober hope (but the dude did love some LSD. He is speculated to be one of the very first users, actually.
Now I'm going towards whats known as Holocaust Verse. Poems written by Robert Celan, Miklós Radnóti, Dan Pagis. They wrote during the holocaust, whether in camps, trains, or labor fields. They found the need to write, often in German. As Kafka described them: “[The Jewish writers] live beset by three impossibilities: the impossibility of not writing, the impossibility of writing in German and the impossibility of writing differently, and we could add a fourth impossibility: the impossibility of writing at all.” It was a strange situation for many of them, native German speakers, now equating their native tongues with death and torture worse than they imagined. I'm bringing this up because it showed that even art is possible in times of unimaginable horror, but afterwards art would suffer, in the mind of Theodore Adorno. Adorno famously coined the phrase "Writing poetry after Auschwitz is barbaric...it is impossible to write poetry today," which has been interpreted a thousand different ways. I see it after such a tragic happening (Auschwitz being used literally and figuratively), art ceases to hold the same meaning. Poetry had a special regard in art for Adorno, who saw it as an escape from typical realist repressions. He later changes from "poetry" to "lyric poetry." He even takes it back even farther in his 1966 Negative Dialektik (Negative Dialectics):
Perennial suffering has as much right to expression as a tortured man has to scream; hence it may have been wrong to say that after Auschwitz you could no longer write poems. But it is not wrong to raise the less cultural question whether after Auschwitz you can go on living--especially whether one who escaped by accident, one who by rights should have been killed, may go on living. His mere survival calls for the coldness, the basic principle of bourgeois subjectivity, without which there could have been no Auschwitz; this is the drastic guilt of him who was spared. By way of atonement he will be plagued by dreams such as that he is no longer living at all, that he was sent to the ovens in 1944 and his whole existence since has been imaginary, an emanation of the insane wish of a man killed twenty years earlier
There is a lack of of optimism after the horrors of war, because, in many ways, there isn't much life to have hope in any longer
I'm by no means an expert about anything European, although I have more than a passing interest in existentialism, which is a philosophical movement that became popularized during the post-WWI period that is commonly viewed as "pessimistic." Honestly, you probably need to parse out a few different things to reach an answer to your question:
Was there a change in popular opinion during the post-WWI period? Did church attendance and other such things drop during this time?
Was there a change in "elite" opinion during the post-WWI period? Did intellectuals, artists, and academics start moving toward a viewpoint that might be characterized as "pessimistic"?
Both of these questions are difficult to answer, but I'd say that our association of existentialism with post-WWI thought at least gives some credence to (2). I'll leave other people to decide whether we can describe existentialists as "pessimistic" - in my own personal life, I've found figures like Albert Camus to offer considerable insight into what it means to be human - but he definitely was focused on issues that aren't exactly pleasant, such as whether life has any objective "meaning" or whether there is any point to living in the first place. He opens what is perhaps his most important essay collection, The Myth of Sisyphus, with a passage that pokes fun at the traditional philosophical concerns:
There is but one truly serious philosophical problem, and that is suicide. Judging whether life is or is not worth living amounts to answering the fundamental question of philosophy. All the rest— whether or not the world has three dimensions, whether the mind has nine or twelve categories—comes afterwards. These are games; one must first answer. And if it is true, as Nietzsche claims, that a philosopher, to deserve our respect, must preach by example, you can appreciate the importance of that reply, for it will precede the definitive act. These are facts the heart can feel; yet they call for careful study before they become clear to the intellect.
Just to give you another example, Jean-Paul Sartre wrote a number of interesting fictional pieces in addition to his philosophical works. One piece that is generally not given enough attention is "The Wall," which is a short story about a prisoner sentenced to death during the Spanish Civil War. While waiting for his execution, he has a revelation:
At that moment I felt that I had my whole life in front of me and I thought, "It's a damned lie." It was worth nothing because it was finished. I wondered how I'd been able to walk, to laugh with the girls: I wouldn't have moved so much as my little finger if I had only imagined I would die like this. My life was in front of me, shut, closed, like a bag and yet everything inside of it was unfinished. For an instant I tried to judge it. I wanted to tell myself, this is a beautiful life. But I couldn't pass judgment on it; it was only a sketch; I had spent my time counterfeiting eternity, I had understood nothing. I missed nothing: there were so many things I could have missed, the taste of manzanilla or the baths I took in summer in a little creek near Cadiz; but death had disenchanted everything.
By "disenchanted," he means essentially that he had begun to see the world objectively, divorced from all the subjective human emotions that we attach to things. And, considered in that way, our lives at their root are meaningless (at the end of Camus' The Stranger, the main character describes death as a wave that rushes overs us, levels all of our experiences, and makes them objectively equivalent). Of course, the existentialists also brought a number of 19th century thinkers into the spotlight, such as Kierkegaard and Nietzsche, who also would be described as "pessimistic."
Not sure if this helps, but if anything, you get an introduction to some interesting philosophical figures.
(I'm ABD at the University of Louisville, degree in English with a concentration in composition/rhetoric. Specialties include 19th century abolitionist rhetoric and studies that examine the transfer of writing skills. No particular expertise in existentialism, although I'd love to teach an existentialist literature course at some point).
EDIT: the grammars
I suggest reading Rites of Spring by Modris Eksteins. It is a cultural history monograph of Europe after World War I. It focuses on certain events, and specifically the reception of them given the post-war period of World War I. I can not begin to summarize it as it was often difficult for me to put into context - details were so fleshed out, I often lost the main points, but that's more a critique. I very much recommend this book for the purpose of understanding the post-war period in terms of culture.
I know at least one historian has argued that the importance of WWI in driving Europeans away from religion is overstated. The historian I'm thinking of is Jay Winter and the work is entitled Sites of Memory, Sites of Mourning. Briefly, Winter argues that modernism is not as iconoclastic as historians have often argued and people retreated into more conservative modes of grieving-rallying around their family, the royal family, and their church. War memorials were commemorated with traditional motifs, not modernist ones, and for Winter even new trends like the popularity of seances and spiritual mediums were actually examples of retreating to older, established forms of grieving. In short, however modern the war was, the grief it caused was expressed through traditional forms, including traditional religious values, that the pessimistic philosophy OP refers to was unable or unwilling to express.