It is important that you understand what is being said in the Scripture you have quoted. The Gospel was not preached to them as you think but do not take my word here is the commentary.
Barnes' Notes on the Bible
Preached before the gospel - This translation does not convey quite the idea to us, which the language of Paul, in the original, would to the people to whom he addressed it. We have affixed a technical sense to the phrase "to preach the gospel." It is applied to the formal and public annunciation of the truths of religion, especially the "good news" of a Saviour's birth, and of redemption by his blood. But we are not required by the language used here to suppose that this was done to Abraham, or that "the gospel" was preached to him in the sense in which we all now use that phrase. The expression, in Greek προευηγγελίσατο proeuēngelisato, means merely, "the joyful news was announced beforehand to Abraham;" scil. that in him should all the nations of the earth be blessed. It was implied, indeed, that it would be by the Messiah; but the distinct point of the "good news" was not the "gospel" as we understand it, but it was that somehow through him all the nations of the earth would be made happy. Tyndale has well translated it," Showed beforehand glad tidings unto Abraham." This translation should have been adopted in our common version.
Barnes' Notes on the Bible
And the Scripture - The word Scripture refers to the Old Testament; see the note at
John 5:39. It is here personified, or spoken of as foreseeing. The idea is, that he by whom the scriptures were inspired, foresaw that. It is agreeable, the meaning is, to the account on the subject in the Old Testament. The Syriac renders this, "Since God foreknew that the Gentiles would be justified by faith, he before announced to Abraham, as the scripture saith, In thee shall all nations be blessed."
Foreseeing - That is, this doctrine is contained in the Old Testament. It was foreseen and predicted that the pagan would be justified by faith, and not by the works of the Law.