Q: I do not understand the context of Psalm 22. Who was David talking to? Was he describing a vision? How can this Psalm be considered Messianic?
A: To answer your question, in Psalm 22 David is seeing a vision of the sufferings of the Messiah and writes up the sufferings and the glory that followed. He was singing Hebrew poetry as all of the Book of Psalms is. He does not describe anything that David himself suffered, but he is describing the sufferings of the Messiah based upon a vision he saw.
The following quotation from our book Messianic Christology (which is a study of Old Testament prophecy concerning the First Coming of the Messiah) will provide you with some more details:
Psalm 22 is the most famous of the Messianic Psalms, the entire psalm being devoted to the events of the First Coming and a few aspects of the Second. The psalm divides into two main parts, the first dealing with the suffering of Messiah, followed by His exaltation in the second. The whole psalm could be viewed as a poetic version of Isaiah 53, although the psalm was in fact written before the prophecy of Isaiah.
These verses find Messiah crying out in deepest anguish. It is no accident that these are the very words that Jesus cried out while hanging on the cross. He quoted these words after a period of three hours of intense darkness. During those three hours the entire wrath of God, due to the sins of Israel and the world, was poured out upon Him. This is the one and only place in the Gospel accounts that Jesus addresses God as “my God.” On every other occasion, and there are over 170 references, Jesus says “Father” or “my Father.” It is made very clear that Jesus enjoyed a very special, unique relationship with God. On the cross, however, Jesus was dying for the sins of the world, and was experiencing a judicial relationship with God, not a paternal one; hence His cry of “my God, my God” instead of “my Father, my Father.”
These verses recount the past deliverances of God. God is fully able to deliver, yet is choosing not to.
These verses describe, in terms similar to Isaiah 53, the taunts and jibes of evil men at the suffering of Messiah. The words used here are indeed very similar to the words of ridicule used by the crowds at the crucifixion of Jesus. He is reproached, scorned, and taunted.
These verses state that Messiah has trusted in God from His birth. There are references here to the mother of Messiah but, as in all other messianic prophecies, there is never any mention of a human father. Messiah would be born of a virgin as prophesied in Isaiah 7:14.
These verses describe the suffering of Messiah, and some of these words are almost quoted in the New Testament.
All of the above must refer to Messiah since clearly none of these things ever happened to David.
Verses 19-21 are again a cry for help from Messiah while still hanging on the cross.
With His suffering complete, verses 22-31 turn and speak of Messiah's exaltation. In verse 22 Messiah will praise God in the midst of the assembly. But how, if He died in verses 1-21 is this possible? Clearly this can only be possible by resurrection. The rest of the psalm goes on to describe what happens after His resurrection, culminating in His Second Coming and the establishment of His kingdom.
Some wish to translate the verse as “like a lion, my hands and my feet,” instead of “they pierced my hands and my feet.” The former is based on the pointing of the Masoretic text and the latter on the Septuagint, a Greek translation of the Hebrew text that preceded the Masoretic text by over one thousand years, and hence closer to the original writing. While it is true that the writer uses several animal motifs in the context, the Psalmist only uses animalistic terms to describe his enemies and not himself. Hence both the context and the antiquity of the Hebrew text behind the Septuagint favor the rendering of “pierce.”