Little is known about the origins of the ancient race known as the Necrons. They were one of the earliest races to appear in the galaxy (the exact time frame is not known). They were originally a race called the Necrontyr, who clung to their short lives (The actual length of life is not certain), fearful of incineration by their large sun. They employed their knowledge to try and find answers for making their lives longer, but to no avail. Then the C'tan were discovered, who offered immortality, but at a price. The Necrontyr accepted this offer with haste, and their souls were encased in living metal bodies. Thus were born the creatures known as the Necrons. What the Necrontyr did not know was that the process made them subservient, and the C'tan made slaves of them. The C'tan needed warrior-slaves to harvest the bodies and lives of the life forms in the galaxy, so that the star-gods could feast on the bodies and souls. After a massive culling which nearly emptied the galaxy of life, the Necrons were placed into stasis, until such a time as life was once more abundant. In the tabletop game "Warhammer 40,000", the Necrons have awakened to a galaxy which is teeming with life once more. At present, the Necrons are a shadowy presence; their full force as yet either hidden or ungathered. They strike as if from nowhere and without warning, slaughtering their enemies and departing before reinforcements can arrive. The origins of these attacks and their motives are unknown, though it is clear that the Necron forces in the galaxy are but the first glimpses of the full might of the Necron war machine.
In addition to direct battle, the Necrons have infiltrated the Imperium of Man to an unknown extent. Their elite anti-psyker troops, the Pariahs, are a cross-breed with human genes, and it is as yet unknown if the Necrons are acquiring individuals with the Pariah gene by themselves or with the help of Imperial traitors (or possibly even elements of the Adeptus Mechanicus).
Little is known of the present goals and objectives of the Necrons. Given that their masters, the C'tan, are interested primarily in consuming the life-energy of living creatures, their goal may simply be to weaken resistance and develop an understanding of the strengths, weaknesses, and motivations of the various species which are currently active in the galaxy. As the Necrons themselves understand it, their goal is simple: eradicate all life within the galaxy. To the Necrons, death is the ultimate peace, whereas life is but a series of primitive conflicts.
Source - Wikipedia