In the day of judgment no condemned sinner will be able to say that God is unjust and that he does not merit God's righteous condemnation. Nor will any saved sinner be able to say that he merited the salvation which God provided for him in grace and mercy. He certainly could, but He chose not to. He did this for all whom the Father had given Him from all eternity. It is for them that He prays in John 17.
Substitution is at the very heart of the gospel.
Christ did not simply give His life to make salvation possible for those who contribute their part to what He has done by repenting and trusting Christ. If they had been His sheep they would have believed. This they will do willingly and with gratitude in their hearts. It is God's work. He cannot fail.