Looking at something in context means also looking at what comes before it. There were no chapter divisions in the Greek; Gal 5:1 follows on immediately from Gal 4.
Then let's break this chapter down.
Galatians 4 (CLV)
1 Now I am saying, for as much time as the enjoyer of an allotment is a minor, in nothing is he of more consequence than a slave, being master of all, 2 but is under guardians and administrators until the time purposed by the father. 3 Thus we also,
when we were minors, were enslaved under the elements of the world."
The elements of the world are not in line with the Law of YHWH.
4 Now when the full time came, God delegates His Son, come of a woman, come
under law, " 5 that He should be
reclaiming those under law, that we may be getting the place of a son."
Paul makes it clear that those who are under the law, are those who have broken the law:
Paul on the Law: Romans Chapter 3
19 Now we are aware that, whatever the law is saying, it is speaking to those under the law, that every mouth may be barred, and the entire world may become subject to the just verdict of God, 20 because, by works of law, no flesh at all shall be justified in His sight, for through law is the recognition of sin."
6 Now, seeing that you are sons, God delegates the spirit of His Son into our hearts, crying "Abba! Father!" 7 So that you are
no longer a slave,
To the elements of the world, sin.
but a son. Now if a son, an enjoyer also of an allotment from God, through Christ."
(CLV) 1Jn 3:9
Everyone who is begotten of God is not doing sin, for His seed is remaining in him, and he can not be sinning, for he is begotten of God.
8 But then, indeed,
having no perception of God, you were slaves of those who, by nature, are not gods." 9 Yet now, knowing God, yet rather being known by God,
how are you turning back again to the infirm and poor elements for which you want to slave again anew?
The elements of the world, sin, transgression of YHWH's law, Paganism.
10 Days are you scrutinizing, and months and seasons and years.
Christmas, Ishtar, SUNday worship, and the rest of the Pagan HollyDays.
11 I fear for you, lest somehow I have toiled for you feignedly." 12 Become as I, for I am even as you, brethren, I beseech you. In nothing do you injure me." 13 Now you are aware that during an infirmity of the flesh I bring the evangel to you formerly. 14 And your trial, in my flesh, you do not scorn, neither do you loathe it, but as a messenger of God you receive me, as Christ Jesus." 15 Where, then, is your happiness? For I am testifying to you, that, if possible, gouging out your eyes, you would give them to me." 16 So that I have become your enemy by being true to you! 17 They are jealous over you, not ideally, but they want to debar you that you may be jealous over them." 18 Now it is ideal for you to be jealous in the ideal always, and not only in my presence with you." 19 Little children mine, with whom I am travailing again until Christ may be formed in you!" 20 Yet I wanted to be present with you just now, and to change my voice, for I am perplexed about you." 21
Tell me, you who want to be under law, are you not hearing the law?
Paul touched on this in Romans 6:
6 knowing this, that our old humanity was crucified together with Him, that the body of Sin may be nullified, for us by no means to be still slaving for Sin,
To be under sin is to be under the law; because what is sin?
(CLV) 1Jn 3:4
Everyone who is doing sin is doing lawlessness also, and sin is lawlessness.
(CLV) Ro 3:31
Are we, then, nullifying law through faith? May it not be coming to that! Nay, we are sustaining law.
Paul is not abolishing the law.
(CLV) Ro 2:13
For not the listeners to law are just with God, but the doers of law shall be justified.
22 For it is written, that Abraham had two sons, one out of the maid and one out of the
free woman."
In covenant, of the promise.
23 But the one, indeed, out of the maid is begotten
according to flesh,
Not working in faith of YHWH's promise; but of your own power.
yet the one out of the
free woman
through the promise:"
Free from The Law of Sin and Death through Faith in YHWH's truth.
(CLV) Ja 1:25
Now he who peers into the perfect law, that of freedom, and abides, not becoming a forgetful listener, but a doer of the work, this one will be happy in his doing.
24 which is allegorizing, for these women are two covenants; one, indeed, from mount Sinai, generating into slavery, which is Hagar."
The law was given at Sinai; but not the promise of Abraham and Sarah. There was however a promise given for keeping the law; but no one had kept it perfectly outside of faith. The fruit if Hagar is of those who keep the law outside of the relationship, no inheritance.
25 Yet Hagar is mount Sinai in Arabia; it is in line with the Jerusalem which now is, for she is in slavery with her children."
An allegory of those who were keeping the law in Jerusalem; but rejected the message of Messiah. They were under under the curse of sin when they fell short of perfection.
26 Yet the Jerusalem above is free, who is mother of us all." 27 For it is written, "Be glad, barren one, who art not bringing forth! Burst forth and implore, thou who art not travailing! For many are the children of the desolate, Rather than of her who has the husband."
Sarah's offspring represent those who are in covenant, who have faith, and act on that faith in obedience to YHWH.
28 Now you, brethren, as Isaac, are children of promise." 29 But even as then, the one generated according to flesh persecuted the one according to spirit, thus also it is now."
Those who were circumcised, not of faith, and not even truly obedient to the Torah, were persecuting those new to the faith in Galatia. They were putting pressure on new converts to be circumcised, before they had matured in their faith. Obedience to the law didn't precede Abraham's faith; therefore this teaching was against Torah. Just as with Baptism, the person who has come to faith, should be Baptized when they have come to a point in their faith; where they have a will to show the outward sign of what has taken place within.
30 But what is the scripture saying? Cast out this maid and her son, for by no means shall the son of the maid be enjoying the allotment with the son of the free woman." 31 Wherefore, brethren, we are not children of the maid, but of the free woman."