Jesus has returned to Jerusalem to celebrate the Feast of Tabernacles (or Booths). While he is there, he is teaching in the temple complex. A large group of Pharisees are questioning him about his identity. Some appear to even accept what he has to say about himself.
Starting in verse 31, however, he speaks directly to the Pharisees who have believed what Jesus has said about himself so far. A true disciple of Jesus will obey his every word and follow him for the long-term. In fact, it is only through following Jesus that a person can be set free from spiritual slavery.
The Pharisees answer that they don’t need to be freed from slavery because they are descendants of Abraham, and thus already children of God. Gerald Borchert explains, in vol. 25A, John 1–11, The New American Commentary,
In contrast to the Zealots, the Pharisees did not regard political liberty as the test of freedom. Being sons of God, a holy people, God’s possession, according to Deut 14:1–2, was for them the test of being free. So being circumcised, according to the rabbinic view, was the guarantee of escaping the bonds of Gehenna just as the people of Israel earlier escaped the bondage of Egypt (Exod. Rab. 19:81; 15:11). Or as the famed Rabbi Akiba reportedly stated concerning the Israelites, even the poor could be proud that they were ‘sons of kings’ because they were sons of the patriarchs (b. Šabb. 128).