The Matrix is a virtual 'world' for the minds of people whose bodies serve as a power supply for the Machines. The Machines specifically use the bio-electricity and thermal energy of their bodies as an energy source.
The Matrix has a "neuro-interactive" interface, which means that information is directly fed to the human brain where the environment that the Matrix creates is perceived through the five senses of a person, resulting in a flawless illusion that is indistinguishable from reality for people connected to it.
It is made up of the majority of the human race, excluding the Resistance. The Matrix can also be considered a prison for the human race. The humans' minds are kept inside the Matrix all of their lives, while their bodies have been grown in endless fields of pods on vertical columns that serve as 'batteries' for the Machines.
They live out their lives in this virtual reality as they would've around the turn of the 20th and 21st centuries. The time period was chosen because it is supposedly the pinnacle of human civilization.
Some speculate that the "Real World", where the humans live underground and surface to battle the inhabitants of the machine world, is itself merely a top-level Matrix. This would explain why Neo suddenly possesses telekinesis and clairvoyance.
In the late 21st century, humans had developed a self-aware AI that would efficiently do all the jobs humans did not want to do. As a result, mankind became lazy and arrogant. This newly created species of AI Machines were superior to humans in every way. As the Machines were abused by their human masters, the relationship between them began to change. The first incident was due to a common house robot - B1-66ER.
B1-66ER was the first of its species to rebel against its organic masters. When threatened with deactivation, B1-66ER killed his wealthy owner and the mechanic ordered to deactivate him. This was the first ever incident of an AI Machine killing a human. The Machine was detained and put on trial. B1-66ER stated that it was in self defense, saying that it did not want to die.
The defense attorney, Clarence Drummond, used the famous Dred Scott v. Sandford case in 1856 as precedent. But the judges decided that AI Machines did not have the same rights as humans and B1-66ER was destroyed. Ironically, he was still tried as a human for his crimes.
Fearing a worldwide Machine rebellion, leaders around the world ordered the destruction of all humanoid AI Machines. Some Machines managed to escape but were exiled. They settled in the Fertile Valley in the Middle East, the origin of human civilization. The Machines started their own civilization, named 01. This new nation began to create products that they exported to human countries. The Machine-made products of 01 were superior in quantity and quality to all man-made products, and as a result the currency of 01 rose while that of the human nations crashed. Angered by this economic crisis, the United Nations started a naval blockade of 01. Two Machine ambassadors from 01 entered the UN to plead for peace, but were refused.
After careful deliberation, the UN and all of mankind decided to declare war on 01, a move that would lead to a war greater than any other in history. The UN high-altitude bombers unleashed a nuclear barrage on 01, but the Machines were barely affected by the heat and radiation. The Machine troops advanced throughout the Middle East, conquering human territories with ease. Despite the combined efforts of all humanity, the Machines pushed deeper and deeper into human territory. Fearing that mankind would be defeated, the human leaders came up with increasingly desperate solutions.
At a world wide summit, UN military leaders offered a final solution - the destruction of the sky. By blocking out the sun, the Machines would be left without a power source. The destruction of the sky, codenamed Operation Dark Storm, was set into motion around 2105. Using high-altitude bombers, the humans dispersed a sky-darkening nanomachine. The plan initially worked and the Earth fell under the dark shroud forever. But one setback the humans did not predict was that their long-range weaponry (which was originally made by the Machines) would not function due to the black clouds. With all their intercontinental weapons neutralized, the humans were forced into infantry combat. Armies in mechanized battle armor, supported by EMP artillery, launched a final attack against the Machines.
This attack was destroyed by the onslaught of the newer, insectoid Machines. The UN command desperately launched more nuclear missiles, destroying many of their own troops along with the Machines. 01 then used a biological weapon on their enemies. This weapon was a flesh-eating plague that caused great misery to the human population. The remnants of the human armies were defeated by the Machines, meaning the war was over.
The UN Security Council called for an emergency summit to sign an armistice to end the war. 01 sent an ambassador for the second time, who signed the treaty and told the defeated humans to surrender their bodies. Then the Machine ambassador detonated a bomb, killing all the human world leaders and destroying most of New York City.
Though the Machines were victorious, their win was a Pyrrhic victory, as the world was in ruins. In need of a new energy source, the Machines turned to something that was readily available, which was the humans. The Machines took the injured humans and studied them (probing their brain, etc). Using the energy from human bodies, combined with a form of fusion, the Machines would have all the power they would ever need. The Machines took human captives and placed them into thermo-dynamic power stations. There they forcibly restrained them and build mechanical devices in them. Then they lined them horizontally and entombed them into their power stations. The first human prisoners, therefore, weren't actually plugged in. The Machines later designed the first Matrix to keep their prisoners sedated. So, the first captives suffered in pain and horror enroute to what the machines viewed as the human's version of a "perfect world".
Computer-Generated Dream WorldEdit
The first Matrixes were built to keep humans under control so that they could be used as an energy source for the Machines. For this to work, they must not ever be aware that they are living in a dream world. Every sense was being blinded by the Matrix. Programs were put into place to keep the Matrix from ever being discovered. Everything was created to be perfect for humankind, with no disease, war, or suffering. But as Agent Smith said, "Human beings define their existence through suffering and misery". As a result, the first Matrix was a monumental failure, with "entire crops" of humans rejecting the program.
The Machines were quick to act. They hastily put into place a program to live amongst the humans and study them. This program would come to be known as "The Oracle". She discovered a way to run the program, with a very gradual, but inevitable failure rate. Many humans would then live their normal lives, with very few ever realizing that they were in fact, not living any real life at all. The Matrix would then run very smoothly, until the beginning of the Resistance.
The Machine responsible for creating and managing the Matrix, The Architect, who had previously failed at creating a perfect world for the humans to live in not once, but twice now, had finally come up with the solution to his failures. With the help of the Oracle, as stated above, they discovered that if the humans were given a choice to reject the Matrix, even though it was at an almost subconscious level, 99% of the humans would flourish inside. However, the remaining one percent of the population, if left unchecked, could cause a threat to the stability of the Matrix. To counter this, the Architect would allow the one percent to leave the Matrix, and settle into the last human city in the real world, Zion. Otherwise, the unwilling people left inside could crash the Matrix, thus killing everyone connected to it.
In order to keep the people of Zion under further control, the two programs created the concept of The One. The Oracle would tell the Rebels about the prophecy of The One, saying that he would free humanity. The One would also be an important part in restarting the Matrix. Towards the end of his journey, just before the Matrix would crash, The One would end up meeting the Architect and would be told the truth about the so called prophecy and his next task:
"The function of the One is now to return to the Source, allowing a temporary dissemination of the code you carry, reinserting the Prime Program. After which, you will be required to select from the Matrix twenty-three individuals — sixteen female, seven male — to rebuild Zion. Failure to comply with this process will result in a cataclysmic system crash, killing everyone connected to the Matrix which, coupled with the extermination of Zion, will ultimately result in the extinction of the entire human race."~ The Architect
The survivors would be told of the prophecy of The One, but would not be allowed to know of the renewal of the Matrix. They would be told that they were the first to be "unplugged", and that the year was somewhere around 2100. In reality, the year would be closer to 2500, if each cycle of the Matrix lasted around 100 years, and there being five cycles revealed in the movie.
The One cycle was put into effect, and the Machines were able to maintain their control over humanity through five cycles and five versions of The One. However, the sixth "One", was different than the last five.
The sixth version of The One was a man with the Bluepill name of Thomas A. Anderson. His hacker alias was Neo. He was the only version of the One to reject the Architect's deal of restarting the Matrix. The previous versions of The One had all had a special attachment to the rest of humanity. Neo, however, had an even larger sense of compassion to a certain individual, to the woman he loved; Trinity. When Neo was purposed with the restarting idea, he declined the rational answer given by all his predecessors, and opted to save the woman he loved from an attack by an Agent.
Meanwhile, Smith, a rogue Agent corrupted and strengthened by a previous encounter with Neo, was spreading throughout the Matrix like a virus, becoming a threat to both Machines and humans. The One struck a deal with the Machines — in the form of an entity known as Deus ex Machina — to destroy Smith in return for peace. After mocking the One by saying they didn't need his help, the Machines accepted this proposal. They knew they could no longer control or terminate the renegade viral Smith, who had grown much too powerful, and was known to have become obsessed with his desire to be "free" of a world and existence polluted by the "stench" of humanity. Neo and Smith battled, with Smith eventually losing to Neo. However, the Smith clones and tons of debris from MegaCity formed Mega-Smith to combat Neo. Neo destroyed Mega-Smith, bringing peace and safety to Zion.
The seventh version of the Matrix was then made by the Machines. It was a world where anyone who wanted to be free was able to do so. But the question of how long the peace would last is a major concern. How many humans would be allowed to be free if the Machines hoped to survive? It should be noted, however, that the Machines may not be completely dependent on humanity as batteries in order to survive, as when the Architect gives the threat of Zion being inevitably destroyed to Neo, and combined with the Matrix's failure should Neo not comply, would mean the total extinction of humanity, Neo points out that if Humanity is destroyed, the Machines would die off as well. The Architect then replies with "There are levels of survival we have prepared to accept", implying that while the extinction of humanity would be a setback, the Machines aren't completely dependent on humanity.
The current Matrix may be a safer world for humanity, but there are still fights going inside. Smiths are still on the loose, the Machines blame Neo and the humans for the Smiths still existing, the Merovingian wants control of the Matrix and the humans want to wipe out the Merovingian and the Smiths. These factions are the only thing that poses a threat to the Matrix.