He was Lazarus' friend, along with Martha and Mary.
(John 11:11-16) 11 He said these things, and after this he said to them: “Laz′a·rus our friend has gone to rest, but I am journeying there to awaken him from sleep.” 12 Therefore the disciples said to him: “Lord, if he has gone to rest, he will get well.” 13 Jesus had spoken, however, about his death. But they imagined he was speaking about taking rest in sleep. 14 At that time, therefore, Jesus said to them outspokenly: “Laz′a·rus has died, 15 and I rejoice on YOUR account that I was not there, in order for YOU to believe. But let us go to him.” 16 Therefore Thomas, who was called The Twin, said to his fellow disciples: “Let us also go, that we may die with him.”
(John 11:20-24) 20 Therefore Martha, when she heard that Jesus was coming, met him; but Mary kept sitting at home. 21 Martha therefore said to Jesus: “Lord, if you had been here my brother would not have died. 22 And yet at present I know that as many things as you ask God for, God will give you.” 23 Jesus said to her: “Your brother will rise.” 24 Martha said to him: “I know he will rise in the resurrection on the last day.”
(John 11:32-36) 32 And so Mary, when she arrived where Jesus was and caught sight of him, fell at his feet, saying to him: “Lord, if you had been here, my brother would not have died.” 33 Jesus, therefore, when he saw her weeping and the Jews that came with her weeping, groaned in the spirit and became troubled; 34 and he said: “Where have YOU laid him?” They said to him: “Lord, come and see.” 35 Jesus gave way to tears. 36 Therefore the Jews began to say: “See, what affection he used to have for him!”
He cried because of empathy, seeing the sorrow that Martha and Mary had. Even though he knew what he was about to do, he felt their pain of seeing Lazarus die, and while they expected to see Lazarus at the resurrection of the last day, the pain of lose was visible.