Jesus raised Lazarus from the dead to glorify God. When Jesus received the news that his friend was sick, he stated in John 11:4, "The sickness will not end in death. No, it is for God's glory so that God's Son may be glorified through it."
Jesus did not go immediately to Lazarus, but instead stayed where he was for two more days. When he finally arrived in Bethany, Martha told him her brother died. Jesus told her that her brother "will rise again," but Martha thought he meant at the resurrection.
Jesus became emotional when he saw how sad Martha and her sister Mary were, and he too cried. He went to the tomb and ordered the stone rolled away. There he prayed, thanking God for hearing his prayer. He wanted those standing around to realize God sent him. He then called for Lazarus to come out of the tomb. Lazarus came back to life at the words of Jesus.