The Tanakh (the Old Testament) is replete with prophecies concerning the Messiah. Beginning with Genesis 3:15, also called the protoevangelium, there are hints, allusions, and explicit references to the identity, the roles, and the work of the promised Messiah.
Jesus explained (likely) every one of them in His conversation with Cleopas and an unnamed disciple as they walked together from Jerusalem to Emmaus after Jesus' crucifixion and resurrection (see Luke 24). Notice the three-fold division of Scripture spoken of: the Law (of Moses), the Prophets, and the Psalms (the "Writings"). The Psalms, of course, is one book in the "Writings" (the others being Proverbs, Ecclesiastes, Job, and eight others), and chapter 22 is considered by many Christians to the most explicitly descriptive passage in the Tanakh concerning the crucifixion of Messiah Yeshua.
This assumption is challenged by many scholars of the Tanakh, but the fact remains that if you were to place Psalm 22 side-by-side with the Gospel accounts of Jesus' crucifixion, the parallels between the two are mind boggling.
Having suggested, then, that much of the content of Psalm 22 goes beyond King David's anguished song of feeling forsaken by his God, I'll simply draw attention to a few of some possible parallels. First, though, here are the Synoptics' version of this incident, which add very little to John's account:
"When they had crucified [Jesus], they divided up His clothes by casting lots. This happened that the Scripture might be fulfilled which said, 'They divided my garments among them and cast lots for my clothing'" (Matthew 27:25). [N.B.: some late manuscripts word this quotation as follows: ". . . lots that the word spoken by the prophet might be fulfilled: 'They divided my garments among themselves and cast lots for my clothing'"]
"Dividing up His clothes, they cast lots to see what each would get" (Mark 15:24b).
"And they divided up his clothes by casting lots" (Luke 23:34b).
Now some parallels:
Psalm 22:1 - "My God, my God, why have you forsaken me? Why are you so far from saving me, so far from the words of my groaning?"
Matthew 27:46 - "About the ninth hour [i.e., about 3PM] Jesus cried out in a loud voice, 'Eloi, Eloi [or Eli, Eli ] lam sabachthani?'--which means, 'My God, my God, why have you forsaken me?'"
Mark 15:34 - "And at the ninth hour Jesus cried out in a loud voice, 'Eloi, Eloi, lama sabachthani?'--which means, 'My God, my God, why have you forsaken me?'"
And then we have
Psalm 22:6-8 - "But I am a worm . . . scorned . . . despised . . ..All who see me mock me . . . hurl insults, shaking their heads [saying] 'He trusts in the LORD; let the LORD rescue him . . . since he delights in Him.'"
Matthew 27:39-44; Mark 15:29-32; Luke 22:35-39:
Passers-by hurled insults at Jesus, shaking their heads and saying, "you who are going to destroy the temple and build it in three days, save yourself! Come down from the cross if you are the Son of God!"
Passers-by said "Come down from the cross and save yourself."
The chief priests, teachers of the law, and the elders mocked Jesus among themselves. They said, "He saved others, but he can't save himself, and to think that he claimed to be the Christ of God, the Chosen One! Here's the Christ, the King of Israel! Let him come down now from the cross, and we will see and then believe in him. He trusts in God. Let God rescue him now if he wants him, for he said, "I am the Son of God."
The soldiers mocked him.
The robbers crucified with him heaped insults on him, and one of them said, "Aren't you the Christ? Save yourself and us!"
N.B.: The words "I am a worm" could be a very graphic depiction of one of the horrors of being crucified; namely, the victim would attempt as best he could to catch his breath by inching his way up the cross (like a worm) in order to relieve the downward pressure on his chest which threatened to asphyxiate him.
Back to Psalms:
Psalm 22:12-13;16, 17b, 20a - Compare David's metaphors to what Jesus experienced on the cross: bulls surround me; strong bulls of Bashan encircle me; roaring lions tear their prey and open their mouths wide against me; dogs have surrounded me; a band of evil men has encircled me; people stare and gloat over me; they divide and cast lots for my clothes; deliver me from the power of the dogs; rescue me from the mouth of the lions; save me from the horns of the wild oxen
Psalm 22:14, 15, 16b, 17a - I am poured out like water; all my bones are out of joint; my heart has melted within me and turned to wax; my strength is dried up like sun-baked clay; my tongue sticks to the roof of my mouth.
Combined, the Gospel accounts describe in literal terms what the psalmist describes in both metaphorical and literal terms. How graphic are the parallels:
being poured out like water on the ground, and the slow death of crucifixion as life ebbs away
bones being out of joint, both references to which could be literal for both David and Jesus
David's metaphorical heart parallels Jesus' metaphorical heart as He experienced more deeply than anyone could ever imagine the heartbreak of bearing the wrath of God against sin, though Jesus himself was the sinless, spotless Lamb of God
a heart turned to wax and melting away, figuratively for David, and both metaphorically and literally for Jesus, since during crucifixion, the heart suffers from edema and eventually becomes a lump of melting wax and then stops beating
Here is an apt summary of what Jesus experienced literally on the cross:
“Psalm 22 is a graphic picture of death by crucifixion. The bones (of the hands, arms, shoulders, and pelvis) out of joint (v. 14); the profuse perspiration caused by intense suffering (v. 14); the action of the heart affected (v. 14); strength exhausted, and extreme thirst (v. 15); the hands and feet pierced (see v. 16, note, but cp. Jn. 20:20 also); partial nudity with the hurt to modesty (v. 17), are all associated with that mode of death. The accompanying circumstances are precisely those fulfilled in the crucifixion of Christ. The desolate cry of v. 1 (Mt. 27:46); the periods of light and darkness of v. 2 (Mt. 27:45); the contemptuous and humiliating treatment of vv. 6-8, 12-13 (Mt. 27:39-44); the casting lots of v. 18 (Mt. 27:35), were all literally fulfilled. When it is remembered that crucifixion was a Roman, not Jewish, form of execution, the proof of inspiration [of Psalm 22] is irresistible” (my emphasis).
In conclusion, Psalm 22 is not just a picture of gloom and doom. The last section of this psalm is filled with confidence and calm assurance that God will indeed hear, rescue, and exalt His servants, whereas the "rich of the earth" will one day "kneel before Him," the one whom they mocked, railed against, and reviled. One day, as Paul, centuries later would say,
"For this reason [i.e., Jesus' humbling of himself, even to a cross-death] also God highly exalted Him, and bestowed on Him the name which is above every name, so that at the name of Jesus EVERY KNEE WILL BOW, of those who are in heaven and on earth and under the earth, and that every tongue will confess that Jesus Christ is Lord, to the glory of God the Father" (Philippians 2:9-11).
Even future generations will proclaim God's righteousness, and they will experience the reality of having Christ's righteousness imputed to them, but only because their unrighteousness was imputed to Christ on the cross (see 2 Corinthians 5:21).