Can you please tell me the story of Sarah and Hagar, because without understanding the story Paul is referring to will never be able to correctly understand how Paul is contrasting the covenants based on the reference.
Since you insist, I refer you to an older commentary by Walvord:
a. The historical facts (4:21-23)
4:21. The Galatians had not yet submitted to the bondage of the Law but they desired to. Paul desperately wanted to stop them and turn them back to a life under grace. As a transition to what would immediately follow, he challenged the Galatians to be aware of or to understand what the Law really said.
4:22. By turning again to Abraham (Gen., as one of the Books of Moses, was considered a part of the Law) Paul was appealing to the founder of the Jewish nation from whose physical descent the Jews traced their blessings. John the Baptist and Jesus declared that physical descent from Abraham was not enough, however, to guarantee spiritual blessing (cf. Mt 3:9; Jn 8:37-44). Paul reminded his readers that Abraham had two sons (those born later are not important to his illustration), and that they should consider which of the two they were most like. One son, Isaac, was born of Sarah, the free woman; the other, Ishmael, was born of Hagar, the slave woman. According to ancient law and custom the status of a mother affected the status of her son.
4:23. A second contrast concerned the manner in which the sons were conceived. Ishmael was born in the ordinary way, that is, in the course of nature and requiring no miracle and no promise of God. Isaac, on the other hand, was born as the result of a promise. Abraham and Sarah were beyond the age of childbearing, but God miraculously fulfilled His promise in bringing life out of the deadness of Sarah's womb (cf. Ro 4:18-21).
In order to emphasize the contrast between Law and grace Paul next used the historical events above as an allegory, that is, he treated those two mothers figuratively (allēgoroumena). He did not in any sense deny the literal meaning of the story of Abraham, but he declared that that story, especially the matters relating to the conception of the two sons, had an additional meaning. Thus he compared the narrative to the conflict between Judaism and Christianity.
(This “allegorizing” is a far cry from the practice of “allegorical interpretation”—followed by Origen, Augustine, and many others down through the ages and into the present day—in which the historical facts are relegated to a lower, less significant level and fanciful, hidden meanings unrelated to the text, are considered vastly more important.)
4:24. First, the apostle pointed to two covenants. One, the Mosaic, had its origin at Mount Sinai. Those under this legal covenant were slaves. As Hagar brought forth a slave, so does the Law. At this point the reader is expected to understand and supply the implicit reference to the Abrahamic Covenant, a gracious system represented by Sarah which through its messianic promise brought forth children who are free.
4:25-26. Next, Paul pointed to two Jerusalems. Hagar also stood for the first-century city of Jerusalem, a city enslaved to Rome and in slavery to the Law. Sarah, on the other hand, corresponded to the Jerusalem… above, the mother of all the children of grace. This heavenly city, which one day will come to earth (cf. Rev 21:2), is now the “city of the living God” (cf. Heb 12:22), the home of departed believers of all ages.
4:27. The quotation from Isa 54:1 prophesied the changing fortunes of Israel, which Paul applied to Sarah's history. Israel before her Babylonian Captivity was likened to a woman with a husband. The barren woman was Israel in Captivity. The woman bearing more… children may have pictured Israel restored to the land after the Exile, but more particularly it portrays her millennial blessings. Paul applied this passage (he did not claim it was fulfilled) in this context to Sarah, who though previously barren, was later blessed with a child, and who would ultimately enjoy a greater progeny than Hagar.
In applying the truth from the biblical illustration, Paul made three comparisons.
4:28. First, Paul compared the birth of Isaac to that of Christians. As “Isaac” experienced a supernatural birth and was a child by means of a promise, so each believer experiences a supernatural birth (Jn 3:3,5) and is a recipient of the promise of salvation (Ga 3:9,22,29). As children of promise Christians are in a distinct category and should not live as children of bondage.
4:29. Second, the apostle compared Ishmael's persecution of Isaac to the false teachers' opposition to believers. Abraham celebrated the weaning of Isaac with a banquet. On that occasion Ishmael mocked Isaac, laughing derisively at the younger boy, since Ishmael was the elder son and assumed he would be heir to his father's estate (cf. Ge 21:8-9). That early animosity has been perpetuated in the two peoples which descended from the two sons of Abraham and is seen in the current Arab-Israel tensions. Paul likened the Judaizers to Ishmael as those who were born out of legalistic self-effort; he charged that they continued to persecute the true believers who were born by the power of the Spirit. With few exceptions Paul's persecution came from the Jews, the people in bondage to the Law.
4:30. Third, Paul compared the action of Abraham to the obligation of the Galatians. When Sarah observed Ishmael mocking Isaac, she asked Abraham to expel the slave woman and her son lest Ishmael become a joint heir with Isaac. And God granted Sarah's request (cf. Ge 21:10,12). This reminded the readers that Law observance brought no inheritance in the family of God, and it also charged them to excommunicate the Judaizers and those who accepted their false doctrines. A fundamental incompatibility remains between Law and grace, between a religion based on works and a religion based on faith.
4:31. In conclusion, Paul affirmed that he and the Galatian believers were not children of the slave woman who was driven away and was denied a share in the inheritance. Rather all believers are children of the free woman, “heirs of God and co-heirs with Christ” (Ro 8:17).