War in Heaven
"You fleshlings think that Horus guy was bad? Back in my day..."
- – Average Necron veteran of the War in Heaven
The War in Heaven was the single most devastating and arguably significant conflict in the history of Warhammer 40,000 -- to give an idea of how mind-boggling huge of a clusterfuck it was, all the deaths and devastation the Horus Heresy wrought to the Milky Way galaxy would be a rounding error in comparison. It is one of the earliest named events, taking place approximately sixty million years before the 41st Millennium (or the Third Millennium aka right now, for that matter, 38,000 years is miniscule compared to sixty million). This conflict is the sole reason as to why the 40k universe is the shitty hellhole we know and love. Of course, we don't know how large the fighting factions really were so who knows.
(Considering that the ENTIRE Milky Way Galaxy became a battleground between the various factions and the countless quintillions in the crossfire it definitely is the largest war in Warhammer history)
Way back then, the galaxy was basically dominated by two civilizations: the Necrontyr and the Old Ones. As the empire of the former grew, it started to fragment, until it was risking collapse. The Triarch decided that a great war was just what the doctor ordered to keep the Empire together, and so they declared war on the Old Ones for not teaching them the secrets of immortality (though, at first, the Necrontyr had only asked for the Old Ones to help them not die horrible, agonizing deaths at the hand of their own star; they refused, which obviously pissed off the Necrontyr). The Old Ones fought back with their Warp technology and psychic abilities, while the Necrontyr used their mastery of the sciences. The destruction was so terrible, and the weapons used so bizarre, that it seemed like the gods themselves were at war, and so this event came to be known as the War in Heaven.
In the end, the Necrontyr were terribly outmatched, as the Old Ones had an insurmountable mobility advantage thanks to their Webway, and the Necrontyr were driven back to the rim of the galaxy for their troubles. This defeat caused even more fractures within the Empire, and so the War in Heaven was put on hold as civil wars flared up again.
This pause in hostilities ended when the Necrontyr made contact with the C'tan and struck a bargain with them, becoming undying constructs of living metal and gaining allies with phenomenal cosmic power for the paltry price of their souls and free will. Thus enhanced, the newly-reforged Necrons resumed the War in Heaven, and this time the Old Ones (who had been significantly weakened by an Enslaver plague caused by their attempts to weaponize the Warp) were defeated.
After destroying the Old Ones, the C'tan were weak from the war, and the Silent King led the Necrons in rebellion, shattering them into thousands of shards, each carefully contained. This, in turn, left the Necrons weakened, and so rather than face (and likely be destroyed by) the Eldar and the various psychic hazards unleashed during the war, they retreated to the safety of millions of Tomb Worlds and entered a deep, sixty-million-year-long hibernation.
Unknown to anyone involved, the Old Ones had fundamentally changed the Warp, corrupting the formerly peaceful Immaterium with the psychic emanations of countless dying races, which eventually clumped together into new warp entities. The rest is heresy.
It is important to note that the Orks and Eldar were created in this time by the Old Ones as living weapons against the Necrons, which is why the Orks can make tech out of anything and why the Eldar are so advanced yet incapable of advancing further. The Orks were designed to produce a psychic field which basically makes whatever they believe become real, weaponizing stupidity - literally. In the Eldar's case, it is because the Old Ones gave them technology, resulting in the Eldar not really comprehending science or engineering and being unable to do anything more than produce what they already have. Ironically, like the Imperium, the Eldar have not tried to understand or learn how to reverse engineer "their" technology and improve it. The Eldar's techno-barbarism - they never even figured out how to make fire - is sometimes used by fans of other factions to mock them.
(The fact that the Orks, Eldar, Old Ones, Jokaero, and other multitude of species at the HEIGHT of their power could not beat the C'tan and the united Necrons shows how terrifying the latter can be.)
Eldar legends also refer to a War in Heaven between Khaine and Vaul, the gods of war and smithing, respectively. After Asuryan sealed the Eldar and their gods apart from each other, Isha and Kurnous (parents of the Eldar) were caught crossing the barrier anyway. As punishment, they were given over to Khaine, who promptly started torturing them. Vaul spoke up for them, and struck a deal with Khaine: one hundred
Baneblades swords in exchange for Isha's and Kurnous's freedom. Since the only thing he liked more than causing pain was weapons, Khaine readily accepted, on the condition that Vaul deliver the blades within a year. Inevitably, when the year was up, Vaul only had ninety-nine blades ready, and so he grabbed a mortal sword and stuffed it in the middle of the pile. Khaine released his prisoners as promised, but when he discovered the fake, he sought bloody vengeance against Vaul, and thus began the War in Heaven.
In the end, Vaul did forge that hundredth blade, and he made it better than all the others, because he intended to use it himself. Unfortunately, war was Khaine's domain, and even though Anaris ("Dawnlight") was by far the superior weapon, Khaine overpowered and crippled Vaul, and chained him to his own anvil, and thus won.
Games Workshop doesn't seem to have a problem with having two big events both called the same thing; the war between the Necrons and Old Ones is called the War in Heaven in both the Third and Fifth Edition Necron Codices, while the War in Heaven of Eldar mythology is mentioned by name and told in the Second, Third, and Fourth Edition Eldar Codices. It is not known if there is a connection between the two, though the Eldar Codices mention "immortal demigod giants" called "Yngir" taking part in the War in Heaven, and the Third Edition Necron Codex says that "Yngir" is the Eldar word for C'tan and that the Eldar legends about their gods say that they were created during "a time of war in heaven" -- though given that the C'tan basically got shoehorned into the setting at the end of Third Edition, and that the Yngir-C'tan connection is not mentioned in the new Necron Codex, who knows if they are separate events, or the same event seen from two perspectives?
There's also a combination of those two events, that the reason Khaine bargained Isha and Kurnous for one-hundred swords is that those swords were "living swords" to be used against the Nightbringer (or as the Eldar call him, the Deathbringer). According to this story, it was Khaine that shattered the Nightbringer into pieces.
Chaos Activity during the War in Heaven(s)
It turns out that Chaos has been active in the Universe much longer than what the Eldar know. Ancient and powerful Daemons, including Slaaneshi ones that look very Eldar-like, threaten Real space back during the War in Heaven(s) (Which maybe a multitude of conflicts instead of one big war or rather extended campaigns and different fronts of one overall Old One + creations and vassals vs C'Tan and Necrons conflict, with proto-Daemons intervening occasionally). This forced the Eldar Empire and certain Necrons to fight together. This explains why the Necrons built all those pylons as opposed to just randomly placing things that would block their enemies psychic powers. (The fact that the Eldar and some Necron Dynasties at the height of their power needed to fight together against Chaos 65 Million Years Ago shows how dangerous they are and just how fortunate Chaos focuses most of their military, time and effort on the Great Game)
Thanks to the Great Rift, these Ancient Daemons are coming back. With both the Eldar and Necrons now mere weak remnants the Galaxy is screwed. Making things worse is that the Forces of Chaos are marshalling more of their mortal and daemonic followers, launching countless invasions against the Eldar, Orks, Necrons and the Imperium.