While the main conflict of Lord of the Rings revolves around the One Ring to Rule Them All, the Dark Lord Sauron's orc army forms the main bulk of the danger facing the Fellowship throughout the War of the Ring. However, they are not to be confused with Saruman's army of Uruk-hai, an offshoot of orc bred personally by Saruman with his black magic.
Sauron's main army of orcs is seen in siege of Minas Tirith, and the grand final battle at the Black Gate. But their true origins and the story of how they fell into Sauron's service stretches all the way back to the very dawn of Middle-Earth, before the awakening of Men.
BEFORE THE FIRST AGE AND MELKOR
Middle-Earth was formed out of the song of the Ainur, who were the creation of Eru Illuvatar, the Father of All. The first Ainur to be named was Melkor, the most powerful of them all. Due to his corrupting influence, he swayed many of the Maiar, lesser divine beings including Sauron himself, to his cause.
After the Earth was created, Melkor was the first to learn of the awakening of the Elves, and before the other Valar can find them, he kidnaps and cruelly tortures some, twisting them into orcs. After the awakening, he sends evil spirits among them to plant seeds of doubt against the Valar, swaying more to his cause. For a time, the orcs remained hidden underground, staying a minor problem until Melkor returned with the Silmarils, beginning the First Age and the War of the Great Jewels.
THE FIRST AGE AND MORGOTH
The First Age of Middle-Earth began with the awakening of Men, and was defined by the War of the Great Jewels, fought between Melkor, now called Morgoth, and the Noldor elves. The orcs would serve as Morgoth's foot soldiers, with their numbers swollen to uncountable levels after centuries of breeding in his fortress of Angbad. They overall proved to be little threat to the Elves, but managed to survive throughout the First Age due to the power of Morgoth.
They were nearly wiped out when Morgoth was cast down at the end of the First Age in the War of Wrath. Those that survived fled to the East, to the mountains of Angmar and the Grey Mountains.
THE SECOND AGE AND SAURON
A few thousand years after his master Morgoth was defeated, Sauron had revealed himself to the world and began building his stronghold Barad-dur in the land of Mordor. He gathered what orcs remained, and began breeding a new army with which to dominate the lands of Middle-Earth himself. While the orc army was being bred, Sauron set out to corrupt the hearts and minds of the races of Middle-Earth. He forged the Rings of Power, and ensnared the Nine kings of Men to his cause.
The Elves, however, rejected his gifts, which brought Sauron into open war with them. The orcs served as the main backbone of Sauron's army, and nearly overran the entirety of Middle-Earth. He was defeated by the Numenorean men, and retreated to Mordor to rebuild his strength. He then eschewed the force of arms in favor of corrupting the kingdom of Numenor, which met with failure when Eru intervened directly, sinking Numenor beneath the waves.
THE LAST ALLIANCE AND THE WAR OF THE RING
Elendil, one of the few Numenorean survivors, set up the realm on Gondor on the borders of Mordor. An enraged Sauron made war with this new kingdom, but was struck down seemingly for good, with his orc armies scattering to the winds. Isildur, who refused to destroy the One Ring, would be slain by orcs, which in turn caused the Ring to fall into the hands of Smeagol, and further into the hands of Bilbo and Frodo Baggins.
By the Third Age, orcs were largely disorganized roving bands until Sauron once again began gathering his strength with the discovery of the One Ring by Bilbo. They formed the bulk of Sauron's army in Mordor, participating in the Siege of Minas Tirith, the Battle of the Field of Pelennor, and the climactic Battle of the Black Gate. With Sauron's final defeat, the orcs were left leaderless and shattered. His entire army was eventually slain, but some populations of orcs remained in the Misty Mountains, although they posed no threat to the lands of Men after the fall of the Dark Lord.