Then he indicates the reason why they were upset, that is, their unbelief. As if to say: the cause of your difficulty is not the hardness of what I have just said, but your own unbelief. And so first, he mentions their unbelief; secondly, he excludes an incorrect interpretation; and thirdly, he gives the reason for their unbelief.
Our Lord indicated their unbelief when he said, But there are some of you who do not believe. He did not say, "who do not understand." He did more than this, for he gave the reason why they did not understand: they did not understand because they did not believe. "I...f you do not believe, you will not understand," as we read in another version of Isaiah (7:9). He said, some, in order to exclude his disciples: "All do not have faith" (2 Thes 3:2); "All do not obey the Gospel" (Rom 10:16); "They did not believe what he said" (Ps 105:24).
The Evangelist then rejects an incorrect interpretation when he adds, For Jesus knew. As if to say: Jesus did not say, there are some of you who do not believe, because he just recently learned it, but because Jesus knew from the beginning, i.e., of the world, those who would believe in him, and who it was that would betray him. "All things are naked and open to his eyes" (Heb 4:13); "All things were known to the Lord God before they were created," as we read in Sirach (23:29).
Source: Commentary on John