My heart goes out to you and your classmates, and especially to the parents of the student who was killed. Almost nothing is harder in life than losing a son or daughter, especially so suddenly.
But God also cares, and I want to assure you that He is touched by this tragedy even more than you and your friends are. No, I don't know why one of your classmates died and the other lived. Many things happen in life that are mysteries to us, and we can only ask God to help us trust Him more fully, even when we don't understand.
But I do know this: God has lessons to teach us whenever things like this happen. For example, this certainly should remind you of the brevity of life and the way it can end in an instant. The Bible says, "Why, you do not even know what will happen tomorrow. What is your life? You are a mist that appears for a little while and then vanishes" (James 4:14).
It should also remind you of the importance of turning your life over to Christ right now and not delaying. God loves us, and He wants to forgive us and give us eternal life if we will only receive Christ into our lives. If you have never done so, ask Him to come into your life today. The Bible says, "We have peace with God through our Lord Jesus Christ" (Romans 5:1).