In the latter part of Genesis, Joseph is rejected by his brothers, and yet not only does he become the hero of the story, the very means by which he is rejected is also the means by which he effects his brothers' salvation. It's like tragedy in reverse. Peter seems to allude to this in his message to the crowd at Pentecost. First, he offers a précis of the situation: Jesus, a Jewish prophet whose wonder-working was a divine endorsement, has been executed by the Gentiles at the behest of his own people. Peter asserts that this was God's plan all along, similar to Joseph telling his brothers "What you have intended for evil, God has intended for good," because it turns out that this is how the Messiah would come to them.
The situation on the ground, I think, is that Jesus threatened the tentative peace between the Jews and their Roman overlords, and the expedient thing, the way to protect that tentative peace, was to have him done away with. There are more dramatic and more rhetorically charged ways of putting this, but that's the basic premise. No one need be particularly evil or capricious for this to take place; in fact, it's a fairly mundane operation of the sociopolitical machine.
Peter tells them that God has raised Jesus up, and that this is not just some miraculous event -- this, too, is a fulfillment of prophecy. Here he does another of Peter's Interesting Psalm Interpretations. He takes Psalm 16, which in context is a proclamation of David's confidence in God's protection. The language is a bit hyperbolic: David trust that God won't let him die. It's like saying "Long live the King" or "God save the Queen" -- that sort of thing. I don't think, in context, it's saying more than, say, Psalm 23 is, though it's not saying less, either. God will protect the righteous. This is the hope of Israel.
Peter reads this as saying that God's chosen servant will never die. David died, ergo David was not the chosen servant. One of his descendants would be. It's not that odd that Jesus would be killed and come back, because he's the Messiah. See what David says here? That's what this Psalm really means. So the bad news is, you killed the Messiah; the good news is, God raised him up and seated him at God's right hand and you can be in on the ground floor of the new regime. Only, by the way, you'll rule by serving and you don't get to kill Romans. Sorry. The Cross wasn't so much a tragic mistake as a new paradigm.
There's a subtext here that doesn't come out so much in this passage but bears attention nonetheless. David died and therefore can't have been the Messiah -- the son of David would be. The son of David would build the temple that David could not because David was a man of war. But it's also not Solomon, who built the temple that got destroyed. That didn't last, so it's not him. And it's not any of the Hasmoneans, or Herod, whose various efforts to rebuild or restore the temple have messianic overtones. That's not going to last, either. These are men of war, ruling by the sword in the ways of the world. The true son of David is Jesus, who is not a man of war, and who is (and/or is building -- there's a lot of stuff there we don't have time for) a temple not made by human hands.
Then Peter tells the crowd, whom he's working into a penitent lather, that "God has made him both Lord and Messiah, this Jesus whom you crucified." This is an interesting turn of phrase, especially from the pen of Luke, who gave us the traditional Christmas story. Oh, sure, Matthew got the Magi and all that, but he's not the one who gets quoted in the Charlie Brown Christmas special. So why does Peter say that God has made Jesus Lord and Messiah? Wasn't he born that way? Wasn't Jesus the rightful claimant to the throne by virtue of his divine parentage and Davidic lineage?
Perhaps it's nothing. A bit of linguistic ambiguity. But we have hints of this in other places, like Romans 1, where Paul tells us that Jesus was declared to be the Son of God by his resurrection, which fits what Peter is saying here. Or Mark's gospel -- which lacks a birth narrative (and might lack a resurrection narrative in its original form) -- in which God says "This is my son" at Jesus' baptism. Or in Hebrews, where God says (quoting a Psalm that we'll see later in Acts) "You are my son; today I have become your Father." On one hand, we have Jesus being born the son of God; on the other hand, we have texts in which this is conferred upon him either at his baptism or upon his resurrection/ascension.
I don't want to make a lot of hay out of this. The broad gist of things is that these texts are claiming that this crucified man is, beyond appearances to the contrary, the long-awaited Messiah. The cross, intended as an instrument not just of torture and execution but also abject humiliation, has been turned into triumph and exaltation. What was intended for evil God has used for good. That claim gets narrated in different ways, like the different voices in a fugue; they have different entrances and are given slightly different treatments, but they contribute to the cumulative effect.
The way Peter describes it -- "God has made him both Lord and Messiah, this Jesus whom you crucified" -- couches things in terms of a divine judgment rendered, a rebuttal to human reckoning. They dispensed with a volatile charismatic leader for the sake of the good of all and unwittingly kill the messiah. It's a twist that would make O. Henry proud. The twist of the twist -- the inversion of tragedy -- is that this is soteriological after all; the fact that killing off the guy who turns out to be the Messiah isn't the tragic end of the story is also a rebuttal to human reckoning.
There's a tautness to the narrative here: the operations of violence and state power that Jesus ultimately renounces are those that kill him. One of the arguments against violent retaliation -- that we might unwittingly make things worse because we know not what we're actually doing -- is played out in the central narrative of this new people God is fashioning. It is part cautionary tale and part myth of origins. Like Joseph, Jesus saves his people through the very mechanism by which they attempt to dispatch him. Unlike Joseph, Jesus does not sidle up to worldly power to get this done, but rather embraces the power of the Cross.