(Note the description implies a full paragon path, alternate outcomes listed below.)
Before Mass Effect 2
Legion's construction in Geth space was meant to serve as an Infiltration unit in organic space. Legion is a self network of 1,183 Geth programs who operate on a unique mobile platform (his body). Legion's head contains several flaps to simulate eyebrow to better communicate with organic life.
Legion was tasked with traveling outside the Perseus Veil and finding Commander Shepherd since he opposed the heretic Geth and the Old Machines (Reapers). Legion in an effort to find Shepherd traveled to numerous sights the commander visited during the commander's investigation of the rogue Spectre Saren Arterius.
Legion visited Eden Prime, Therum, Feros, Noveria, Virmire, Illos, and several uncharted worlds before finding the original Normandy's crash site on Alchera. While on Eden Prime Legion was attacked by Alliance soldiers and sustained a rifle shot to his chest.
This left a large hole which he patched with N7 Armor from the crash site on Alchera. This armor was Shepherd's own armor and when questioned why he didn't patch it sooner Legion responds with "no data available" implying the decision was irrational and not usual of the Geth, further showing off its uniqueness.
Mass Effect 2: The Derelict Reaper
Legion is first encounter by Shepherd and the crew of the Normandy SR-2 on board a derelict Reaper orbiting Mnemosyne, a brown dwarf. Shepherd was their to find an IFF device in order to penetrate the Omega 4 relay and Legion was their in order to gain further information on the Reapers. Legion was surprised to see Commander Shepherd alive and saved the group from a husk ambush. Legion was the first Geth to speak to Shepherd.
When Shepherd arrived at the Mass Effect Generator core Legion was already working on the console though was attacked and deactivated by a husk. Shepherd and the crew destroy the core and take Legion's deactivated mobile platform aboard the Normandy for study since Legion was not acting like the Geth Shepherd had seen before. Legion was stored in the AI Core of the Normandy SR-2. Miranda Lawson was in favor of sending the Geth to Cerberus for an active cash bounty while Jacob Taylor wanted Legion destroyed.
Shepherd had Legion reactivated while EDI erected additional firewalls to prevent hacking. Legion shows no hostility towards Shepherd and requests to join his team in fighting the Collectors and Reapers. Legion does not have its name yet and when Shepherd asks he simply says Geth. EDI quotes the Bible Gospel of Mark 5:9 "We are Legion for we are many". This is suited as an "appropriate metaphor" and Legion gets its name.
When speaking to Legion it will either answer with a very straight forward one word answer or if sentences are needed they will be highly organized thoughts. Legion will speak about the Geth heretics and how the Reaper Sovereign swayed them to his side. Legion will discuss topics about its own Geth and the "Morning War". Legion will playback the first recording of a Geth asking he he had a soul which frighted the Quarians into trying to exterminate the Geth. Legions last conversation details how the Geth are construction a massive station with the closest human analog being a Dyson sphere so all Geth programs can be uploaded and never be alone again.
Mass Effect 2: A House Divided
Legion while go to Shepherd with an urgent request concerning the Geth heretics. The heretics had developed a Reaper based virus in order to corrupt Geth and turn them into followers of the Reapers. Legion explains that the virus causes errors in their most basic run times and changes all higher thought processes.
The virus is housed in a Space station between stars because organics have no reason to look there. Legion needs the stealth system of the Normandy in order to get close to the station. The Normandy's stealth drive is particularly effective on Geth craft since Geth do not use windows, they are a structural weaknesses.
Shepherd and Legion infiltrate the Geth Station and Legion brings up the point that since the virus is complete Legion could re-purpose it to brainwash the heretics back into the Geth. Since this is new data Legion takes the mission to process and reach a consensus.
During the mission Legion finds evidence that the heretics have run times in the Geth networks and are spying on them. This confuses Legion as the heretics were allowed to leave and the nature of Geth is to share all data and knowledge. It does not make sense why the heretics would spy on the true Geth. Once in the Central Station chamber Legion poses the question of whether to rewrite the heretics or blow the station to Shepherd. Legion is split between the issue with 573 programs favor rewriting and 571 favor deletion.
Legion says Shepherd has perspective the Geth lack since he has fought the heretics. Shepherd not wanting to kill the Geth has them rewritten and the team evacuates before a large EMP of 1.21 petawats fires through the station and travels through FTL channels.
Mass Effect 2: The Collector base and beyond
Legion traveled with Shepherd and the rest of the crew to the Collector base and assaulted it alongside the rest of the Normandy crew. After Shepherd was asked to return to Alliance space to answer for the death of 300,00 Batarian colonists, Legion left to return to the Perseus Veil and report to the Geth consensus. The Geth than began to prepare for war with the Reapers while finishing construction of their Dyson sphere like housing.
While construction was nearly complete the Quarian fleet began a war to retake Rannoch and bombed the structure not knowing what it truly was. This caused the death of a large number of Geth programs. Since Geth network to gain intelligence this greatly narrowed the Geth's perspective and survival became a priority. The Geth accepted an offer from the Reapers. The Reapers uploaded their own code to increase the intelligence of the Geth and their fighting ability while the Reapers maintained control of the Geth.
The Reapers played the signal through a Geth dreadnought of considerable size. Legion was against this decision but was used as a booster for the signal and placed inside a machine on the dreadnought. The Geth fleet could now fight off the Quarian assault and had them trapped inside the system as the cover the Mass Relay.
Mass Effect 3
Commander Shepherd first encounters Legion when the Normandy's crew infiltrates the Geth Dreadnought and frees it from the Reaper machine. Though some newer squad members will express negative feelings over Shepherd knowing a Geth by name they free him and Legion disables the Dreadnoughts weapons, shields, and kinetic barriers. The mission was to disable the dreadnought so the Quarian fleet could flee and join the war effort.
Admiral Han'Gerrel vas Neema instead has the Quarian Heavy Fleet bombard the dreadnought in order to destroy it almost killing Legion and Shepherd who use a Geth fighter to escape. This ruins the Quarians chance at retreat. Legion then accompanies Shepherd aboard the Normandy where it meets Admiral Raan who is distressed at the sight of the Geth and Admiral Xen who wants to dissect Legion. Legion will show the Admirals and Shepherd who the Reaper code has upgradeed the Geth and that Geth units can now be considered alive.
The Geth themselves find this "Beautiful". Legion will also state that while he is no longer broadcasting the Reaper signal their is a short range signal coming from Rannoch itself. Legion spends his time in the Normandy's War Room trying to locate the Reaper base where the signal is broadcast.
Legion will reveal a Geth Fighter Squadron hub to Shepherd and the Admirals. Saying its destruction would help the Quarian liveships survive the battle. The Admrials approve of the destruction of the server hub and Legion accompanies Shepherd on this mission.
During the shuttle ride down Legion reveals the mission involves Shepherd actually going inside the Geth consensus virtually through an interface adapted from the Cerberus project Overlord. Shepherd inside the Geth consensus sees important events in Geth history such as the first Geth to come online and receive the Geth name, The Geth first proposing the question of his soul, The first Geth to pickup a weapon, Quarian sympathizers protecting Geth from Quarian police, The Geth allowing the Quarians to leave Rannoch, and Shepherd agreeing to work with the Geth.
When Shepherd askes why the last one is important Legion reveals that Shepherd was the first organic to cooperate with the Geth since the "Morning War" 300 years ago and that The Geth did not want to forget it. Once Shepherd takes the hub offline the Geth Fighters stop attacking Quarian liveships and Legion reveals their was a secondary purpose to the mission. Legion was albe to convince Geth programs to join its cause and upload into powerful Geth Prime mobile platforms. These Prime are sent to Admrial Hackett of the Alliance for support.
Legion is able to locate the Reaper base and accompanies Shepherd on the mission. Shepherd takes a targeting laser to pinpoint a vital area the Normandy can it. During the shuttle ride Legion reveals he has some if the Reaper code inside himself so he can counteract any defensive measure the Reapers have put in place. Legion displays a level of shame over this though realizes the benefits. Legion separates from Shepherd's team to disable defenses and acquire an escape vehicle. Throughout the mission Legion disables base defenses and guides Shepherd to an area where he can paint the target.
Once Shepherd has the Normandy strike the base it is revealed the signal is coming from an actual Reaper. Legion drives a Geth land vehicle while Shepherd mans the guns firing at the Reaper. Shepherd will use the targeting laser liked to the Quarian Heavey fleet to destroy the Reaper. Once done the Quarian begin attacking the disable Geth ships and Legion proposes using the Reaper code to upgrade all Geth into true AI's. Tali'Zorah will adamantly vote against this as the Geth will fight back and destroy her people. Shepherd allows Legion to upload the code while he and Tali convince the Quarian fleet to stand down. This allows both fleets to survive. Legion at 80% upload will note that it is not enough and upload its own personality to complete the transfer.
In Legion's last moments it refers to itself as "I" instead of "we" showing that it has become an individual instead on an avatar of the Geth consensus. Legion "dies" on Rannoch saving the Geth and giving them their intelligence. A Geth prime the approaches Shepherd, Tali, and Admiral Raan and says the Quarians are welcome to return to Rannoch and the Geth will honor both Legion and its promise to help Shepherd retake Earth from the Reapers.
Powers and Abilities
Legion is a gestalt intelligence and an avatar of the Geth Consensus. Legion is a combination of 1,183 Geth programs loaded onto a unique mobile platform. Legion as a squad mate is a tech type character who can release drones to aid in battle while wielding an assault rifle and sniper rifle.
Legion is shown very proficient with the sniper rifle as his machine reflexes are much faster than an organics. Legion is very durable being able to survive an Alliance rifle shot that ripped a clear hole in his chest and still continue as if noting happened with only basic patchwork.
Mass Effect 2 - Legion can have several fates in the game. When Legion is first acquired Shepherd may turn it over to Cerberus for a large cash bounty in which case Legion will appear on Cronos Station as Legion Assassin under Cerberus control wielding an M-13 Raptor sniper rifle and must be killed by Shepherd. Alternatively Legion can die during the suicide mission against the Collector base. In either case a Geth VI based on Legion before he found Shepherd will take its place and peace between the Quarians and Geth will be impossible forcing Shepherd to choose a side.
Mass Effect 3 - If Shepherd chooses to have Legion upload the code, but cannot convince the Quarians to stand down then the know Intelligent Geth will destroy the Quarians. If Shepherd chooses the Quarians then Legion will attack Shepherd and grab him by the throat reminiscent of Saren in the original game. Legion will then be either stabbed by Tali or if she is dead shot be Admiral Xen's shotgun.