"I have nothing to offer but blood, toil, tears, and sweat."
- – Winston Churchill
"The day of small nations has long passed away. The day of Empires has come."
- – Joseph Chamberlain
" To ravage, to slaughter, to usurp under false titles, they call empire; and where they make a desert, they call it peace."
- – Calgacus,Caledonian chieftain
" Rise up, Humanity! Rise from the ashes! Claim your birthright! SPACE!!!"
- – The Emperor of Mankind, If the Emperor had a Text-to-Speech Device
The Great Crusade was an important event in the history of Warhammer 40,000, seeing the formation of the Imperium of Man and reunification of humanity, and is basically the best time to be alive - If you are a loyal subject of the Emperor, that is. If not, you are endangered by just being in this galaxy, and try as hard as you can to stay out of the Imperium's reach until they are done with their megalomaniacal crusade.
The Emperor Emerges
For much of the 20,000's, Terra and the other human colonies were consumed by war after the rebellion of the Iron Men, an era later known as the Age of Strife. The techno-barbarians (uhn tiss uhn tiss uhn tiss baby) ruled little fiefdoms on once-proud Terra, and all hope seemed lost.
Then the Emperor of Mankind appeared in M28, and started conquering Terra piece by piece in the Unification Wars. His army consisted of the predecessors of Space Marines, the Thunder Warriors, using prototype powered armor that wasn't even void-sealed (of course they still had massive pauldrons), who were in fact preposterously OP even relative to Marines millennia later but unsustainable collectively and genetically unstable individually.
This was approximately the time that the Emperor decided that religion was bad for humanity and violently implemented the Imperial Truth, the conclusion of which can be seen in the story The Last Church. The reason why the Emperor's being atheist is so weird and doesn't click into the lore smoothly is because originally there was nothing atheist about him or the Imperium, to say nothing about how literally not a single cause of the fall of the Dark Age of Technology had anything to do with religion (to wit, humanity's race of sapient android houseslaves rebelled en masse, dozens of enslaved or uprooted alien species launched simultaneous campaigns of revanchism for their colonized star systems, and the birth of Slaanesh caused human psykers across the galaxy to lose their sanity or control of their powers while warp storms grew cataclysmically common and powerful while the creatures of the Warp multiplied and invaded like swarms of locusts.) So shoehorning him into that doesn't work well at all.
The Next Step
Of course, Terra wasn't enough for the Emperor; he wanted to rule over all of Humanity. He had already arranged for the Void Dragon to be sealed on Mars so that by this time in history he would have the Adeptus Mechanicus to build awesome weapons for his armies; now he needed some armies to wield those weapons. And to lead those armies he needed generals, so he started the Primarch Project in M29, creating twenty super-human warriors: his sons and his generals. The Gods of Chaos perceived this project to be a threat to them, so they scattered the Primarchs throughout the galaxy courtesy of a dick who just happened to be their mother, causing them to undergo experiences which would eventually turn many of them against their father. Still, the Emperor had enough data to create his Space Marine Legions based on their DNA in what would later be called the First Founding (and was at the time known as the Only Founding). He sent the Legions out to find their Primarchs and to reunite humanity's scattered colonies as they went.
The Age of the Imperium
Over the course of the next two hundred years or so, the Space Marine Legions found their Primarchs and the Imperium of Man grew world by world, until it spanned almost the whole galaxy. Many Xenos species were exterminated along the way, as well as non-Imperial human civilizations like the Interex, as the Emperor believed them to be a threat to his dominance. Between this directive and the influence of his Slaaneshi daemon blade, Fulgrim wiped out many Eldar worlds, resulting in mutual animosity between the Imperium and the Eldar for millennia to come; of course, considering the Eldar had been frequently raiding human worlds throughout the Age of Strife, tough shit. It was generally considered a pretty fun move on Fulgrim's part. To be fair, though, nearly all the xenos killed had descended upon human worlds during the Age of Strife and turned them into "Nightmare Worlds" and "Hell Worlds". As you might imagine, the crusading Imperium was not amused. In fact, most worlds added to the Imperium were of this sort, which went a long way to entrenching humanity's hatred of all things alien. Even the Jovian colonies in the Sol system were pretty much horror-infested hellholes ruled over by incalculably cruel alien overlords. Some examples of worlds liberated included electricity-blasting worm things that literally bred and harvested humans like cattle and a species that used tortured human souls as power generators.
When Eldrad tried to contact the Emperor to warn him that he should be more concerned with stopping Chaos than with expanding the Imperium, the Emperor refused to listen to him, both because Eldrad ordered his forces to attack Fulgrim upon realizing the Primarch was corrupted without realizing that Fulgrim was not yet corrupted by the sword and could still be saved (also attacking a Primarch is unbelievably stupid if you want to live). It didn't hurt that the Emperor's creation of the Imperium was performed in a way crafted by Him to specifically act as an anti-Chaos civilization by virtue of being not only massive but also atheist (alas, he didn't realize faith hurt Chaos until the very end of the Horus Heresy). What's more, Eldrad's orders were the reason for Eldar raids - not something that screams trustworthiness, especially when the raiders hail from a post-scarcity society and so have literally no reason to go raiding but for teh lulz. The Emperor was probably also aware of the Eldar's plan to create a god made of Eldar souls to combat Slaanesh, an entity that actively drains and devours Eldar souls for funsies. Yeah, probably not a good idea to let the space elves succeed at that one.
After the Ullanor Crusade, the Emperor announced that he was returning to Terra, saying that his sons were to prove that they were the leaders he had made them to be. He appointed Horus, Primarch of the Luna Wolves, as Warmaster of the Great Crusade and withdrew to the Imperial Palace. In truth, the Emperor was ready to begin his next phase of star travel, creating a Webway portal under the Palace using the Golden Throne. Unfortunately, the Emperor's detachment from humanity created a great deal of rivalry and resentment among his sons, and his failure to fully explain matters to them only exacerbated the situation. The Ruinous Powers were quick to take advantage of these weak spots, and slowly but steadily began to corrupt some of the Primarchs.
This culminated with the Horus Heresy.
- The Last Church, a short story taking place towards the end of the Emperor's conquest of Terra in which a priest wins an argument against the Emperor about religion and both of them prove ignorant of the actual history of the ancient Crusades (unless the Emperor's using them as an example and proving himself wrong intentionally was a sort of wink at the readers by the author; if he is as old as implied, he definitely knows what actually happened).