shadowās backstory is bonkers and largely in subtext/supplemental material to a 20 year old game but itās SO important to him as a character
50 years before the events of the main games, eggmanās grandfather, gerald, was tasked with creating the ultimate lifeform. the president at the time commissioned the project as a way to achieve immortality, something gerald thought was an overstep of science, but his granddaughter, maria, was born with an incurable terminal condition (the fictional NIDS, obviously meant to invoke AIDS) so he agreed to the project to help save her life.
the project was developed on an orbital space colony, which allowed a perfectly controlled environment for maria to live in, and the distance from the government meant they didnāt have extremely strict oversight of what was going on.
so project shadow goes ahead, and a number of things are created as a result - namely, a prototype ultimate lifeform, a volatile and powerful lizard which has grown uncontrollable, and the true ultimate lifeform, shadow. the lizard is so dangerous that it gets locked away in the depths of the colony, but shadow is a polite little guy and gerald ends up raising him alongside maria. (according to shadowās own game, his genes were stabilized by the blood of an alien literally called black doom, but this really isnāt as important as you would think)
eventually word leaks down to the government on earth about the prototype, being interpreted as the ultimate lifeform itself being an uncontrollable danger, and the military launches an attack on the colony to forcibly shut down the project. they arrive under the guise of responding to an emergency, and in order to keep the silence about the government being involved with something like project shadow, completely evacuate the civilian personnel of the colony to shut it down, then murder everyone involved in project shadow. during the massacre, shadow and maria attempt to run to an escape pod together, but maria gets shot by a soldier (!!!) and forces shadow into the escape pod alone. her last act is to ask him to be kind to the people on earth and send him away, while he watches helplessly and knows sheās dying.
so shadow makes it to earth, but the military captures him anyway, and lock him up on an island military base while they decide what to do with him. gerald is there as well, kept alive because he knows everything about shadow and can make him useful to them. gerald is completely broken over what happened on the colony and to maria specifically, though, and vows revenge on all of humanity. he reprograms shadow to carry out this revenge by implanting false memories about mariaās last wish for him, and when the government realizes what he did, orders his execution by firing squad (!!!!!) and locks shadow in stasis to keep him from destroying the world.
50 years later, eggman gets wind of his grandfatherās ultimate weapon and its whereabouts. he breaks into the base, releases shadow, and plans to use him to take over the world. shadow plays along, but is really just aiming to fulfill his last promise to maria, which he thinks is to wipe out humanity.
and then the events of sa2 actually happen and idk if you want a summary of that too but tldr he realizes what mariaās true wish was very late into the story and then sacrifices himself to stop his creatorās plan and protect the people of earth for her and itās very š„ŗš„ŗš„ŗ