Jesus displays for us in person the compassion of God for his suffering saints. God in the flesh is able to demonstrate for us what God in heaven feels when we cry out to him in moments of grief or sorrow.
There are certain theological systems of belief that hold to the idea that God is unmoved emotionally by the human condition. That God has already fore-ordained and set things in motion from eternity and is therefore not swayed by whatever humans may do in time and space. This is called "immutibility." But Jesus came to earth to reveal God to us, and this story reveals the heart of a loving and compassionate God who is fully capable of grieving along with his creation. When Mary fell at Jesus feet, even knowing what he was about to do, Jesus was visibly moved. He burst into tears and wept along with Mary and the other mourners. So much so that John 11:36 records the Jews saying, “See how he loved him!” I am glad to know that our God is compassionate and moved to grieve along with his creation. Jesus is the one who revealed that aspect of God’s nature during his time on earth.