There are essentially two halves to the story behind the universe of Warhammer 40,000 (or WH40K for short), and they are divided chronologically. The first half, having been originally written as the only WH40K setting, takes place in the modern 41st millennium. Most books set in this time period begin with an introductory page that looks like this:
"It is the 41st millennium.
Yet even in his deathless state, the Emperor continues his eternal vigilance. Mighty battlefleets cross the daemon-infested miasma of the warp, the only route between distant stars, their way lit by the Astronomican, the psychic manifestation of the Emperor’s will. Vast armies give battle in His name on uncounted worlds. Greatest amongst his soldiers are the Adeptus Astartes, the Space Marines, bio-engineered super-warriors. Their comrades in arms are legion: the Imperial Guard and countless planetary defence forces, the ever-vigilant Inquisition and the tech-priests of the Adeptus Mechanicus to name only a few. But for all their multitudes, they are barely enough to hold off the ever-present threat from aliens, heretics, mutants – and worse.
To be a man in such times is to be one amongst untold billions. It is to live in the cruelest and most bloody regime imaginable. These are the tales of those times. Forget the power of technology and science, for so much has been forgotten, never to be re-learned. Forget the promise of progress and understanding, for in the grim dark future there is only war. There is no peace amongst the starts, only an eternity of carnage and slaughter, and the laughter of thirsting gods."
"…10,000 Years Earlier
The Horus Heresy
It is a time of Legend.
Mighty heroes battle for the right to rule the galaxy. The vast armies of the Emperor of Earth have conquered the galaxy in a Great Crusade – the myriad alien races have been smashed by the Emperor’s elite warriors and wiped from the face of history.
The dawn of a new age of supremacy for humanity beckons.
Gleaming citadels of marble and gold celebrate the many victories of the Emperor. Triumphs are raised on a million worlds to record the epic deeds of his most powerful and deadly warriors.
First and foremost amongst these are the Primarchs, superheroic beings who have led the Emperor’s armies of Space Marines in victory after victory. They are unstoppable and magnificent, the pinnacle of the Emperor’s genetic experimentation. The Space Marines are the mightiest human warriors the galaxy has ever known, each capable of besting a hundred normal men or more in combat.
Organised into vast armies of tens of thousands called Legions, the Space Marines and their Primarch leaders conquer the galaxy in the name of the Emperor.
Chief amongst the Primarchs is Horus, called the Glorious, the Brightest Star, favourite of the Emperor, and like a son unto him. He is the Warmaster, the commander-in-chief of the Emperor’s military might, subjugator of a thousand thousand worlds and conqueror of the galaxy. He is a warrior without peer, a diplomat supreme.
As the flames of war spread through the Imperium, mankind’s champions will all be put to the ultimate test."
This prequel story arc tells the story of the schism between the brothers of the Space Marine Legions, and is currently in the process of giving a very complete and detailed account of what happened ten thousand years previous to the current timeline. The thing that makes this historical account interesting is its ability to inspire my sense of wonder about Earth history. What if we all of a sudden had a written account of what happened throughout all of human history? It would be rather amazing.
In addition there are an unlimited number of online resources dedicated to this all-encompassing storyline, most of which can be found linked to a simple Wikipedia search for Warhammer 40k.