Then when he says, Search the Scriptures, he gives the third way in which God bore witness to Christ, through the Scriptures. First, he mentions the testimony of the Scriptures. Secondly, he shows that they were not able to gather the fruit of this testimony (v 40).
He says: Search the Scriptures. As if to say: You do not have the word of God in your hearts, but in the Scriptures; therefore, you must seek for it elsewhere than in your hearts. Hence, Search the Scriptures, that is, the Old Testament, for the faith of Christ was contained in the Old Testament, but not on the surface, for it lay... hidden in its depths, under shadowy symbols: "Even to this day, when Moses is read, a veil is over their hearts" (2 Cor 3:15). Thus he significantly says, Search, probe into the depths: "If you search for her [wisdom] like money, and dig for her like a treasure, you will understand the fear of the Lord and will find the knowledge of God" (Prv 2:4); "Give me understanding and I will search your commandments" (Ps 118:34).
The reason why you should search them I take from your own opinion, because you think you have eternal life in them, since we read in Ezekiel (18:19): "He who has kept my commands will live." But you are mistaken; because although the precepts of the old law are living, they do not contain life in themselves. They are said to be living only to the extent that they lead to me, the Christ. Yet you use them as though they contained life in themselves, and in this you are mistaken, for they bear witness to me, i.e., they are living to the extent that they lead to a knowledge of me. And they lead to a knowledge of me either by plain prophecies, as in Isaiah (7:14): "A virgin will conceive." or in Deuteronomy (18:15): "The Lord your God will raise up a prophet for you."; and so Acts (10:43) says: "All the prophets bear witness to him." The Scriptures also lead to a knowledge of Christ through the symbolic actions of the prophets; thus we read: "I have used resemblances in the ministry of the prophets" (Hos 12:10). Knowledge of Christ is also given in their sacraments and figures, as in the immolation of the lamb, and other symbolic sacraments of the law: "The law has only a shadow of the good things to come" (Heb 10:1). And so, because the Scriptures of the Old Testament gave much testimony about Christ, the Apostle says: "He promised the Good News before, through his prophets in the holy Scriptures; the Good News of his Son, a descendant of David in his human nature" (Rom 1:2).
Source: Commentary on John