It's a good question. The first thing to understand is that, Jesu is considered God by xians. That is a major aspect of the religious beliefs. The Bible, therefore, should be read in that light. So, we can surmise that Jesu is not saying these words completely literally, in fact, they are probably the words of a hymn or such. I have created a thread asking this same question, however the ''literal'' interpretation, is unlikely, imo, whatever the actual answer is. I simply avoid the issue altogether by only using a gospel that doesn't contain these words, as I believe they are confusing, and since unexplained in the text, not clear enough to be in my included Scripture.
First of all, it is Christendom ( so-called Christian but in name only ) who consider Jesus as God.
Gospel writer John wrote at Revelation 1:5; 3:14 that Jesus is the beginning of the creation by God.
God had No beginning - Psalm 90:2 - so Jesus was Not before the beginning as God was before the beginning.
By Jesus saying ' why have you God forsaken me ' shows that God was Not helping Jesus to lay down his life.
Jesus was laying down his life of his own free choice, his own free-will choice.
Jesus' words show that Jesus was Not being comforted by God, but that Jesus was really released or abandoned into the hands of his enemies dying completely out of love for us. Notice what was most important to Jesus according to John 12 vs 27,28,33