Short history of necrons:
About 60.000.000.000.000 years ago, there was a race known as the Necrontyr. They lived in great tomb cities, and had incredibly short lives, as their star was too volatile too allow them life. Desperately, they set out for the stars, only to meet the Old Ones. The Old Ones were an even older race of intelligent beings with hyperadvanced technology. The old Ones were able to extend their lifespans virtually forever, and yet refused to share this technology with the Necrontyr. This pissed off the Necrontyr, and this anger united them into a war they could not win against the Old Ones. Through superior technology and control over the Warp, the Old Ones beat back the Necrontyr until they were nothing more than a couple of planets around their homeworld, no longer a threat.
It's unknown how the Necrontyr first made contact with the C'Tan. The C'Tan were massive metaphysical solar parasites, feeding off of the immense energy of stars. The Necron worshipped these beings when they discovered them, and believed that in these beings lay there one hope of rebuilding their empire, and attaining immortality. They built specialized bodies out of Necrodermis and, through unknown means, condensed the massive star-parasites into these bodies. The C'Tan were originally quite pleased with this, happily accepting the worship of the Necrontyr and spending their time being lazy and spoiled. However, one of the C'Tan (who would be known later as The Deceiver) had a plan. He went up to the Silent King of the Necrontyr, and told him of a nonexistent war between the Old Ones and the C'Tan. He spun a tale of defeat and revenge, and stated that if the Necrontyr were to aid the C'Tan in defeating the Old Ones once more, the C'Tan would grant the Necrontyr the immortality they sought.
Seeing both of their goals represented in this deal, the Necrontyr leaders happily agreed. The C'Tan prepared massive conversion facilities, and exchanged the physical, fleshy bodies of the Necrontyr with the far superior Necrodermis bodies of the Necron. However, there was a hidden clause to this deal. Even as their minds were imprinted onto the robotic bodies, their souls were removed from them, and devoured by the C'Tan. For while they drew sustenance from the sun, they found that souls were far more delicious. And the Silent King watched as his people were turned dull, their creativity, their individuality, drained from them. Some retained more than most, those with more advanced necrodermis bodies could pass through the process with their entire personalities left intact. But the majority of the Necron race was transformed into mindless machnes.
Then there was the war, known as the War in Heaven. The Silent King was given absolute control over all Necron, and advanced C'Tan technology, and he lead the armies of the Necron against the Old Ones. While they lacked psykers due to their lack of souls, the Necron more than made up for it in durability and advanced technology. The C'tan joined in on the assault, unstoppable Gods of Death who could smash entire worlds with ease, blacken out suns, and create new black holes. The old Ones first created the Orcs, powerful psychic beings with incredible physical strength and speed, capable of turning everything into a weapon. When the Orcs failed to turn back the enemy, they created the Eldar, frail but fast psykers who could exploit the slow movement of the Necron.
However, it was not enough. The Old Ones were defeated and murdered, the C'Tan feasted on their Souls, and the Necron became the unchallenged rulers of the galaxy. They started Red Harvests, slaughtering half a planet's population on a yearly basis to feed their greedy deities, ritual sacrifice on a much larger scale. Hundreds of lesser species were subjugated and the C'Tan grew lazy and fat on the souls of the living.
However, the Silent King was kind of a badass. And when he saw what had become of his people, when he saw the true form of the empire he had been promised, he decided to kill the C'Tan. That's right, the Necron marched against the C'Tan. The unstoppable Gods of Space and Time able to annihilate entire solar systems. The Necron flung their full forces at the C'Tan, using wormhole technology, quantum computing and hyperadvanced weaponry to defeat the Star Gods. And they won. They shattered the C'Tan into pieces, and locked each of these pieces in a hyperdimensional prison known as a Tesseract. A self-repairing prison that seperated not just the C'Tan's power, but also their consciousness. Some of the C'Tan were even completely destroyed.
But because of this battle they were too weak to exterminate the Eldar, who had flourished in hiding. As such they locked themselves in the Tomb Worlds and decided to wait for 60.000.000.000.000 years, until all life in the galaxy had died out and the Eldar were nothing more than a faded memory. Which is why they're waking up right about now.