shepard did everything right.
Please note: Because Miranda first appears in Mass Effect 2, there are by necessity some spoilers for the first game in this section. In addition, there are some spoilers for the opening of Mass Effect 2 in here. If you've managed to avoid spoilers for the opening of ME2 — and it's the kind of opening you really don't want to be spoiled for if you're planning on playing it! — please don't read this page. Trust me, and just go play the game.
The Mass Effect trilogy is set just shy of 200 years in our future. Humanity has achieved faster-than-light travel after discovering ruins on Mars from the long-extinct Protheans, who were wiped out 50,000 years ago. This led to the subsequent discovery of the mass effect field and element zero, and shortly afterwards, the mass relay system that allows for rapid travel through the galaxy.
The First Contact War of 2157 was humanity’s first brush with alien species. They soon found that lying beyond the mass relays was a thriving galactic community made up of many different alien races. While the galaxy has no single ruling entity, the largest group is the Council, based on the Citadel. Its leaders, made up of the first three races to reach the Citadel (the asari, salarians, and turians), guide galactic politics and policies. Humanity established the Systems Alliance following the discovery of extraterrestrial life, encompassing both its military and political interests in the galactic theater.
Humanity began expanding into the galaxy at a rapid pace, establishing colonies through different systems, leading to friction with some alien races already in those areas, such as the batarians. The Eden Prime War, which took place in 2183, involved a rogue Spectre (a special agent reporting directly to the Council and thus above the law) and his geth forces. After becoming a Spectre, the Alliance soldier Commander Shepard was involved in these conflicts, ultimately leading to the Battle of the Council, in which the Reaper Sovereign was destroyed at great loss of life. (This is the plot of the first Mass Effect.)
Cerberus is only mentioned a couple of times throughout the first Mass Effect game, and never in a particularly kind manner. If there are shady things going on, chances are they're probably involved in some way. Shepard never encounters Cerberus directly, but can come across a few outposts where their experiments have run amok and have to run cleanup duty. All of these missions are sidequests, so players who skipped out on them may not even know Cerberus was in the first game at all. (I was one of these players my first time through — I had a lot of trouble getting into the game and just wanted to hurry up and press on to the next one.)
Miranda is introduced at the very beginning of Mass Effect 2. By design, Mass Effect is a game with a malleable protagonist — Shepard's gender and appearance are entirely up to the player, and player choices are kept when importing save games. ME2 took an interesting route in order to to allow players to redesign their Shepards between games, in that at the beginning of ME2 your trusty ship gets blown up and Shepard gets killed.
That's where Miranda comes in. As head of the Lazarus Project, and on Cerberus's dime, she spends the next two years rebuilding Shepard from scratch, breathing new life into his or her body. Because Cerberus has a mission for Shepard that's worth the time and effort: human colonies are disappearing, and the hero of the galaxy needs to figure out what's going on.
Miranda serves as the second-in-command aboard the Normandy — that is, the new one Cerberus helpfully builds, thanks guys — and reports on Shepard's doings to the Illusive Man, Cerberus's leader. She's an expert in biotics (space magic), and is forthcoming about her past: she's a test tube baby, a clone of her father, literally designed to be "perfect." She rebelled against his upbringing, and Cerberus gave her refuge.
But it's never that simple, is it?