War in Heaven
The War in Heaven was the single most devastating and arguably significant conflict in the history of Warhammer 40,000 -- in fact, it is one of the earliest named events, taking place approximately sixty million years before the 41st Millennium (or the Third Millennium, 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 also 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 both why the Orks can make tech out of anything and why the Eldar are so advanced yet incapable of advancing further. In the first, 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 the Eldar's technology resulting in the Eldar not really comprehending science and such 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 science to reverse-engineer "their" technology and improve it. The Eldar's techno-barbarism and that they never 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?