Romans 15:4  For whatsoever things were written aforetime were written for our learning, that we through patience and comfort of the scriptures might have hope.

Clark’s commentary
That therefore we must go and do likewise: For whatsoever things were written aforetime were written for our learning. [1.] That which is written of Christ, concerning his self-denial and sufferings, is written for our learning; he hath left us an example. If Christ denied himself, surely we should deny ourselves, from a principle  of ingenuousness and of gratitude, and especially of conformity to his image. The example of Christ, in what he did and said, is recorded for our imitation. [2.] That which is written in the scriptures of the Old Testament in the general is written for our learning. What David had said in his own person Paul had just now applied to Christ. Now lest this should look like a straining of the scripture, he gives us this excellent rule in general, that all the scriptures of the Old Testament (much more those of the New) were written for our learning, and are not to be looked upon as of private interpretation. What happened to the Old Testament saint happened to them for ensample; and the scriptures of the Old Testament have many fulfillings. The scriptures are left for a standing rule to us: they are written, that they might remain for our use and benefit. First, For our learning. There are many things to be learned out of the scriptures; and that is the best learning which is drawn from these fountains. Those are the most learned that are most mighty in the scriptures. We must therefore labour, not only to understand the literal meaning of the scripture, but to learn out of it that which will do us good; and we have need of help therefore not only to roll away the stone, but to draw out the water, for in many places the well is deep. Practical observations are more necessary than critical expositions. Secondly, That we through patience and comfort of the scriptures might have hope. That hope which hath eternal life for its object is here proposed as the end of scripture-learning. The scripture was written that we might know what to hope for from God, and upon what grounds, and in what way. This should recommend the scripture to us that it is a special friend to Christian hope. Now the way of attaining this hope is through patience and comfort of the scripture. Patience and comfort suppose trouble and sorrow; such is the lot of the saints in this world; and, were it not so, we should have no occasion for patience and comfort. But both these befriend that hope which is the life of our souls. Patience works experience, and experience hope, which maketh not ashamed, Romans 5:3-5. The more patience we exercise under troubles the more hopefully we may look through our troubles; nothing more destructive to hope than impatience. And the comfort of the scriptures, that comfort which springs from the word of God (that is the surest and sweetest comfort) is likewise a great stay to hope, as it is an earnest in hand of the good hoped for. The Spirit, as a comforter, is the earnest of our inheritance.