Certainly, before the crucifixion Jesus knew all that would transpire. But perhaps the actual experience was more intense than He had anticipated. Suffering prepared Him for His role as our great High Priest (Heb. 4:14-16).
Bible students make two statements about His cry of anguish. First, it is taken from Psalm 22. That messianic psalm (a psalm abut the Messiah) begins with the very words Jesus articulated on the cross: "My God, my God, why have you forsaken me?" Second, Jesus may have intended to draw attention to the psalm, to make the connection between its words and His identity. Additionally, I think the cry was wrung from Him as He experienced the awful cost of being the sin-bearer of sinful humanity-from Adam to the last human being to be born.