"The mistake we make is to attribute to religions the errors and fanaticism of human beings."
- – Tahar Ben Jelloun
"There can be daemons in a secular cosmos, Garviel. Just as long as we understand the use of the word."
- – Warmaster Horus, Horus Rising
"The Truth will come out. You won't be able to hold the blindfold in place, and once it slips, the fury of those you deceived will be limitless."
"Thou hast also written that prayer and supplications have been offered by thee, that I might find a good entry into Baptism. This prayer of thine... I have not understood."
- – Güyük Khan to Pope Innocent IV, in a diplomatical letter written in persan
The Imperial Truth is the atheist rationalist doctrine espoused by the Emperor of Mankind as part of the Great Crusade. According to the Imperial Truth, the Emperor believed that religion and superstition had divided mankind too much during its history. On one hand, the Emperor had reason to believe since he'd lived through most of Terra's religious wars (although his statements about them in The Last Church implies he either actually didn't bother knowing anything about them or he was purposefully lying to try and win an argument, both sound like him). On the other hand, these were motivated by secular reasons, defensive responses or fanatics who would have simply attached their obsession to something else if they had no religion at the time. Thus did the Emperor become an extreme militant atheist who violently purged the religions of Terra. His plan was for Imperium of Man to become a secular state espousing science and reason (based on the Emperor's conjectures linking religious worship to the powers of Chaos, as seen below). Although, the science and reason thing didn't shake the religious trappings and presence (such as angelic figures, demons, and various vernacular and art quirks of the Imperium).
Unsurprising; it's easy to convince someone that there is no buff guy in the sky throwing lightning bolts when you can prove it, but when confronted with something like "everything exist because God says so, the end" you can't really disprove it since anything you use was "created by God" or religions focused on an afterlife because A) can't be dis-proven even in 40K and B) souls actually do go to the other side of the Warp assuming nothing catches them and so that would actually encourage afterlife religious belief. Following the Horus Heresy and the Emperor's internment on the Golden Throne, the Imperial Truth collapsed, the Emperor's very own philosophy denounced as HERESY wherever it was not simply forgotten, and the Imperium of Man has become a theocratic dictatorship where questioning anything results in a painful death. So, exactly what the Emperor wanted just with worship instead of atheism as its official religious belief.
Its probable that, given the massive proliferation of Chaos-lite cults throughout the galaxy after the Age of Strife, from tribal practices that wouldn't be out of place in Norsca to complete theocracies, the Emperor didn't want to take any chances and just banned any religious practices regardless of whether or not they were more or less obviously connected to Chaos. Even in the 40th millennium, part of their modus operandi still involves infiltrating and corrupting otherwise legitimate religious and philosophical institutions, after all. However, that is only due to how common they are. Secular organizations are just as vulnerable. More so, even, due to lacking the shield of faith nearly so strongly as that in religious-focused groups.
While the Emperor was viscerally against religion as a concept, attributing to it many of the woes that had plagued Mankind's history, he didn't just ban and purge religion simply because he disagreed with it. During his millennia of existence, the Emperor had come to partially determine the nature of the relationship sentient life had with the Warp. Knowing that the belief in gods would only serve to create them and empower the Warp creatures, the Emperor hoped to starve the Chaos Gods by denying them worshipers. Because creating and worshiping loving gods who protected humanity from the extremes Chaos represented would be a bad idea because...? Oh, right, da Emprah was also a control-freak to a degree.
This was doomed to failure from the get-go since the Emperor had failed to realize that the Chaos Gods were powered not only by faith, but also by raw emotions. People going about their daily lives experiencing their normal emotions would still empower the Chaos Gods. Also the same behaviors and traits some, such as the Emperor, hated and associated with religious people are also found among the non-religious. He also failed to realize that faith was actually the greatest weapon against the Chaos Gods, what was needed was an alternative to direct the belief at such as a God, a God-Emperor or the religions that existed at the time before Emps decided to go all Stalin on them. In fact, the Emperor may even have BEEN Stalin and Soviet Russia - the first nation in history with an avowed goal of purging religion and replacing it with atheism - might have been a precursor to the Imperial Truth. Faith enables a Guardsman to kill a daemon (sometimes) because that Guardsman believes so utterly that it becomes real for that daemon. Given the deeds of normal humans in the fluff which do not even involve daemons and still amount to things even a Space Marine would be impressed by, it is likely that faith and the Warp related to humanity goes beyond just fighting Chaos. Heck, look at the Acts of Faith for the Sisters of Battle as an example. Freaking Living Saints, even (potentially).
The final deathblow for his case came when proof was found during the Horus Heresy that faith in something else, and by extension other religions, actually hurts Chaos. While a non-religious creed against Chaos (like what the Interex had) can fend them off, at most this would achieve a stalemate until a controlled psyker decided to go outside the lines. But theistic religiosity proved superior since it gave the means to actually take the fight to Chaos, beat them back and, MAYBE... one day, even defeat the Chaos Gods. Or maybe that Eldar god made of Eldar souls will succeed in slaying a Warp god that specializes in eating Eldar souls...yeah, that’s going to end perfectly.
An alternative view is that the Emprah's plan wasn't to actually kill the Chaos Gods but to remove them from the Materium (in hindsight we know how hilariously ridiculous that idea is). The Emprah had a few major pet-peeves: religion, uncontrolled psykers, unregulated xenos and warp travel. Without Cultist-chan and chaos-worshiping xenos, there would be no summoning of daemons. Without uncontrolled psykers, few possessions would occur. Without warp travel, there would be few opportunities for Chaos Gods to fuck Man up. Thus, without religion, xenos, psykers and warp travel, the Chaos Gods and their minions wouldn't be able to access the Materium (for the most part). Who gives a shit if the Chaos Gods are powerful if they are unable to do shit with that power? Answer, Emprah knows BEST!!!! (Although the Emprah withholding this knowledge from nearly everyone, including his own sons who are out on their own all over the galaxy, probably wasn't the best idea since knowing the enemy is the first step in fighting it.) However there was one big problem with this idea in the form of the Eye of Terror, which would still be providing a connection between the Materium and the Immaterium even in Emps purged religion, uncontrolled psykers, warp travel and aliens (not to mention humans are fallible and entropy is a thing, so a controlled psyker can become an uncontrolled one).
Unfortunately, any doctrine based upon scientific materialism and skepticism doesn't work in practical terms in a universe where gods are real and active (whether you believe in real life or not, they are most definitely there in 40k) / eternal & ethereal souls exist / people come back from the dead / technology is animistic / prayer actually works / sorcery does not require being a psyker / failure to burn enough witches at the stake makes your world a putrid mess with rivers of pus / Red 'Unz do go Fasta! / and the second most (technologically) advanced alien race in the setting is practicing Polytheism, works on prophecies and ghost powered mechanized support plus summoning an avatar of one of their gods. Chaos in particular is especially irreconcilable with such things, as everything about it is contradictory and unpredictable. Not only will trying to observe it make you go insane, replicating it would almost certainly destroy all of reality even if it didn't work.
The Tau tried treating things scientifically on Kronus (Eldar weapons), Kaurava (Living Saints), and Medusa V (analyzing a warp rift). In the first two cases they could not understand a thing about how they worked, and on Medusa they basically made the scientific equivalent of "Here be dragons". Still though, chaos gods HATE the Tau both for the greater good ideology that opposes all the principal aspects of the chaos gods (peace over war, health over disease, meritocracy over ambitious backstabbing and not excessives allowed) and got the control over the civil population to actually make it happen.
Still, why wasn't the Emprah more straightforward? He could have said: "There are no gods, just alien dimension energy beings that are so fucked up, they think they are Gods. They are lying and will fuck you over." But he probably didn't do that since the whole idea of the Great Crusade was to eliminate such creatures, and telling everyone about them like that would only lead to overzealous idiots making contact with 'the monsters' in an attempt to cage or eliminate them (a trait sadly common in his sons), and that would open its own can of worms. Another reason for him not to tell anyone is that what counts as a "god" is entirely up to each individual person. To the Greeks, Zeus and Poseidon were gods. To the Christians, Zeus and Poseidon either do not exist or do not count as gods because they are more limited than the Christian God. It's all subjective, which means telling people about Chaos and daemons would still cause huge numbers of people to decide they're gods which A) would make them stronger due to that belief even if the believers hated them and tried to fight against them and B) a lot of the people would start worshiping and following them like wet-rot under the carpet.
The Emprah's own biggest fuck up was not trusting Mankind or even his own Primarchs to be able to cope with the actual truth of the matter, the existence of eldritch entities in general without falling on our knees to worship them. Extra stupid points since the war against the Men of Iron happened after a daemonic invasion of human space, to say nothing of the Age of Strife's frequent wars against daemons. Humanity had more than proven that we weren't going to join the fuckers. The Emprah was like a manager that hides vital information from his employees because he doesn't think they can cope with the big picture, then the company falls apart when an engineer pisses off a major customer because of some unknown piece of said info. That is WH40K in a nutshell.
Perhaps it was more than anything the fact the Emperor knew in his heart of hearts too many people resented the Great Crusade, as in all wars there is a losing side, even if they became part of the Imperium there is still lots of people who saw their worlds shattered, they would be the first ones to give Chaos a try, not because they need to believe in something but as an attempt to escape their deplorable condition and take revenge upon those who enslaved them.
If the Imperial Truth is even known about by the time of 40k is uncertain, although more than likely the term is now used as pro-imperial propaganda by Imperial Missionaries trying to sell worship of the Emperor to disbelieving locals on your newly discovered savage world. In fact the novel Hammer & Anvil flat-out says that's what it is. Some Chaos Space Marines might remember it, but due to their worship of the Chaos Gods none of them follow it, with the exception of Fabius Bile.
Most Space Marine chapter and the Adeptus Custodes as a whole also teaches their forces their own versions of the Imperial Truth. However because the Imperium needs the Emperor's elite creations and would not survive without them. The Inquisition officially considers their beliefs considered variants of the Imperial Cult. Well, that and the problem that if they called out the Astartes, the Astartes and their supporters would point out that the Astartes beliefs are what the Emperor told them to believe, so only a dirty heretic would try to stop them.
* Note the word "wasn't" is strictly past tense, which is kinda important.
Originally, atheism wasn't part of the fluff. Possibly first appeared in the Horus Heresy novels. And since "everything is canon" in 40K, it could easily be passed off as nonsensical historians attempting to piece together the Great Crusade and getting something ridiculous and hypocritical to the point there would have hardly been any planets left after the Great Crusade finished as most worlds above feral would have questioned why the Imperium was destroying everything that didn't match the "official" histories of religion when those destroyed records were the same throughout the galaxy and only the Imperium's take was different. Questioning the Imperial Truth is an excellent way to be burned at the stake. Or on a pile of history books that disagree with the official narrative.
The point is that the Imperial Truth comes off as beyond even 40k’s standard of stupidity because the setting had been heavily developed long before the atheism thing was injected into it. As a result, it’s less like shoving a square peg through a round hole and more like trying to play checkers on the board of holes and wondering why your chess pieces keep falling through.
That, and killing the people smart enough to actually learn things instead of assuming "common knowledge" is magically right and reject logic and reason to not feel dumb doesn't exactly encourage the Emperor's vision for humanity.
That said, how strongly the Imperial Truth was enforced very clearly varied from Legion to Legion. Case-in-point: Word Bearers. And religious people clearly still lived in the Great Crusade as something to ridicule by the government though to what degree of secrecy varied dramatically wherever they were. By and large, it seems likely the Imperium took the approach that if your religion can be disproven, it will be destroyed, if your religion cannot be disproven (such as belief in God creating everything or an afterlife) then active worship will be banned (probably for fear of split loyalties between religious and secular authorities which admittedly has caused a number of hardships in human history) and anyone believing in the religion would be mocked as weirdos. A “happy” balance between “feed the Christians/Jews to lions” and State Atheism in which religion can be ruthlessly purged but when the Imperium cannot actually disprove a religious belief it didn’t just murderize everyone...unless the Emperor was personally leading the conquest of your world. Then yeah, he’d totally kill everyone but Monarchia seems to imply he grew out of that after realizing the scope or he’d have killed everyone there instead of evacuating them before destroying it.
The Emperor not destroying the Machine Cult makes sense in this context. Allowing the worship of knowledge and science is basically worship of the Imperial Truth, which is something it's not surprising he'd tolerate. Allowing worship of "love thy neighbor" and "you go to a happy place when you die" probably wouldn't have bothered him either. Allowing worship of "lightning comes from an old due on a mountain throwing bolts like javelins" isn't tolerable.
Though there is the implication that the Emperor arranged for the Machine Cult being created during the DAoT. See the Omnissiah for the theories.
Primarch's point of view
When Horus had a vision of the 41st millennium, part of his instant patricidal rage was that the Emperor was abandoning the Imperial Truth by seeking to become a real god (which made the Emperor a hypocrite if true). This in turn convinced him to renounce the Emperor. And then start worshiping the Chaos Gods. It’s double hypocritical when you realize that he could only get pissed at the belief his father was trying to become a god if Horus believed gods existed otherwise he’d think it was impossible. So, he broke the Imperial Truth in order to be able to believe the Emperor planned to break the Imperial Truth and then he broke it again by worshipping Chaos to stop the Emperor from breaking the Imperial Truth (Look, Horus was a dumbass).
Magnus said that the Warp is just another type of knowledge to be used. The Warp, in turn, made him its bitch. Even ignoring that, there is nothing "possible, observable, and repeatable" when it comes to the Warp (before Mortarion fell to Chaos he believed this and attempted to put it into practice, which got him fucked up by a Daemon he wanted to interrogate), and many other things in 40k. It's well, chaotic, the hate, anger and madness of uncountable beings in the Galaxy. There is nothing rational about the emotional refuse of sentience, and trying to apply scientific principles to them is a waste of time at the absolute best.
During Jaghatai Khan's first visit on Terra, he didn't not have a great time with his father, kept butting words with him. He also didn't think highly of Malcador, kept delaying his meeting until his psyker buddy Yesugei convinced him to go. There the Khan and Malcador had a discussion about the Imperial Truth, which the Khan believe it to be a load of bullshit, a giant hypocrisy that can only delay the inevitable, even compare it to the slaves from his planet, where they are promised freedom when is ready, except it never came and some had to rebelled. Malcador replied by saying the lie is noble and necessary, which is why they need the Primarch to get their asses to conquer planets fast before the lie expired.
Guilliman himself still believe in (at least modified version of) it after his return, and after being saved by a Living Saint during the Plague Wars he's seriously started to wonder if Lorgar and the Ecclesiarchy actually had it right all along. Even if he genuinely believed that the Emperor was telling the truth when he told Lorgar that he was no god, its entirely possible that he may more or less have become a god in his current state. He doesn't worship him, but does recognize that if he wasn't a god back then, he definitely is now.