Then when he says, for whatever things were written, he shows that we must imitate this example of Christ, saying: for whatever things were written in Sacred Scripture about Christ or his members were written for our learning. There was no need to write this except for our instruction: all Scripture is inspired by God and profitable for teaching, for correction, and for training in justice (2 Tim 3:16).
But what is contained in Scripture for our instruction is shown when he says: that, through patience and the comfort of the Scriptures, i.e., which the Scriptures contain. For in Sacred Script...ure is contained the patience of the saints in enduring evils: you have heard of the patience of Job (Jas 5:11). In them is also contained consolation, which God gave them, as it says in a psalm: when the cares of my heart are many, your consolations cheer my soul (Ps 94:19). Hence it also says in 1 Peter: predicting the sufferings of Christ, which pertains to patience, and the subsequent glory, which pertains to consolation (1 Pet 1:11).
What the fruit of this doctrine will be for us he indicates when he says: that we might have hope. For by the instruction from Sacred Scripture that those who suffered tribulations patiently for God were divinely consoled, we receive the hope that we ourselves will be consoled, if we have been patient in them: if he should slay me, I will hope in him (Job 13:15).
Source: Commentary on Romans