There are a number of things you have to do throughout the game in order to get everyone to survive the suicide mission. You have to get all three ship upgrades for the Normandy. (Shield, Armor, and Thanix Cannon Weapon) You have to complete the loyalty missions for all party members. You have to either use charm or intimidate conversation options in the scene where Jack and Miranda confront each other, same in the scene where Tali and Legion confront each other, in order to not lose loyalty on one of the two characters.
Finally, you have to pick specific squad members when you are given the option. The squad leader must be either Garrus or Miranda in both instances. The technician that goes into the vent must be either Tali, Legion...