Jesus started out by giving instructions to his disciples for this short-term mission he's sending them on, but now he begins to launch into an epic sermon on the persecution believers will suffer to the end of the church age. He says they will first deliver you up to their synagogues, the religious court, then they will deliver you up to governors and kings, the secular court. And actually this is what happened to Jesus. He was arrested and brought before the high priest first, then he was delivered up to Pilate. The same happened to Paul. He was seized by the Jews and brought before the high priest, then he was brought before the governor and the king "as a testimony to them and to the Gentiles."
By putting the religious court first, Jesus seems to be hinting that if you're following him, you'll find yourself on the opposite side of some powerful religious establishment. You see that in his ministry. He tends to get wary when the Pharisees come around. He instructs his disciples to follow their leaders' teaching but not their example. And while he utilizes the temple and synagogues as a places to gather and teach, he doesn't speak of them with particular reverence. In his mind leadership positions and places of worship are institutions of men. "Beware of men, for they will deliver you up to the courts and scourge you in their synagogues." When it comes to persecuting Jesus' followers, the religious leaders will be the first in line, not the atheists or secularists. It is they who will deliver you up to the secular authorities.
When human beings set up their courts, particularly a religious court, they are seeking to imitate the judgment of God. The true court of judgment is in heaven above, but the earthly courts can have that same feeling of doom. And when a trial is conducted in a religious context it can be extremely intimidating. There is comfort in knowing that Jesus has already faced such a court both before the high priest and before Pilate. When he says not to become anxious about what to speak because his Spirit will give us the words, he is not just drawing from his divine wisdom but from his human experience.
It is incredible to think that he, the Creator and Lord of the universe, once stood before a human court to be pronounced guilty by wicked men. And yet when it comes our turn to be condemned in a similar fashion, though we are more deserving of judgment and he was not, Jesus' only thought will be to comfort us in our distress. Whatever we might suffer in this life, Jesus has already gone before us so that he could walk beside us when no other friend would.