Habakkuk 1:13 Thou art of purer eyes than to behold evil, and canst not look on iniquity: wherefore lookest thou upon them that deal treacherously, and holdest thy tongue when the wicked devoureth the man that is more righteous than he?
Genesis 6:5 And God saw that the wickedness of man was great in the earth, and that every imagination of the thoughts of his heart was only evil continually. 6 And it repented the LORD that he had made man on the earth, and it grieved him at his heart.
Both these verses above shows that God did not forsake Christ while He hung on the cross, but that it grieved him at His heart that the world became so sinful that He had to give His only begotten Son to be the final blood sacrifice that through Him and those who come to Him can have eternal life with the Father, John 3:16. This was God's divine plan in the beginning, even before the foundation of the world.
Psalm 22:1 My God, my God, why hast thou forsaken me? why art thou so far from helping me, and from the words of my roaring?
Psalm 22:24 For he hath not despised nor abhorred the affliction of the afflicted; neither hath he hid his face from him; but when he cried unto him, he heard.
Matthew 27:45 Now from the sixth hour there was darkness over all the land unto the ninth hour. 46 And about the ninth hour Jesus cried with a loud voice, saying, Eli, Eli, lama sabachthani? that is to say, My God, my God, why hast thou forsaken me?
God never forsook Jesus as deity can not be separated. Comparing the above verses in Psalms and Matthew Jesus was declaring to His accusers as He hung on the cross that they were in the midst of fulfilling Psalms 22. The psalmist himself understood that the forsaking of God was not abandonment, but a lifting of His Sovereign protection according to His divine plan so the threats of His enemies could be carried out in prophecy. There were many times during Jesus ministry that the enemy wanted to kill Him, but they couldn't as His time had not yet come from above, John 7:30
2 Corinthians 5:21; 1 Peter 1:19 Jesus, a lamb without spot or blemish. God made Jesus to take upon all our sin and nail it to the cross. Jesus who knew no sin that we might be made the righteousness of God in Him.