The passage in Romans 11:5-6 discusses the shift from a covenant of works to a covenant of grace.
gotquestions says:
Much of Romans and Galatians addresses the fact that there is only one
way of salvation and only one gospel message. Throughout history
people have tried to pervert the gospel by adding human works to it,
requiring certain things to be done to “earn” salvation. But the
Bible’s clear message is that the way of salvation has always been
through faith. In the Old Testament, it was faith in the promise that
God would send a Savior someday. Those who lived in the time of the
Old Testament looked forward to the Messiah and believed God’s promise
of the coming Servant of the Lord (Isaiah 53). Those who exercised
such faith were saved. Today we look back on the life, death, and
resurrection of the Savior and are saved by faith in Jesus Christ’s
atonement for our sins (Romans 10:9-10).
No one was saved by works.
No one at any time was ever saved by works, self-effort, or by keeping
the Mosaic Law. Works-righteousness could never attain to God's
perfect standard, but were as useless as "filthy rags" (Isa. 64:6). In
the New Testament, Paul also explains that no one is justified by
keeping the Law (Rom. 3:20;). Though the Law was powerless to save, it
led people to Jesus, who does save (Gal. 3:19-24). Paul refers three
times to Abraham as the consummate example of justification by grace
through faith (Rom. 4:3; Gal. 3: 6; James 2:23; for James' perspective
on Abraham's justification see GraceNotes no. 2 "Faith and Works in
James 2:14"). Abraham was saved before circumcision and the Law were
instituted, so he could not have been saved by keeping them (Rom.
4:9-12; Gal. 3:16-18). Obedience to the Law and its sacrificial system
allowed fellowship with God and prefigured the final necessary
sacrifice of Jesus Christ. Mosaic animal sacrifices were only
provisional, never sufficient for salvation (Rom. 3:25; Heb. 10:1-4).
Paul makes it clear that salvation cannot be earned through works, as it is a gift of grace. Works and grace are incompatible in the process of salvation. God's election is solely based on His grace, not on works.
It is crucial to comprehend that in Israel, those who did not adhere to the law faced consequences! Nevertheless, it is important to recognize that salvation has always been attained through grace through faith, even during the Old Testament times. The Mosaic Law was implemented temporarily to expose sin and guide individuals towards their requirement for a Savior (Galatians 3:24). However, mere obedience to the law was insufficient for salvation. It was faith in God's promises, including the assurance of a future Messiah, that ultimately brought about salvation.
Ananias and Sapphira's transgression went beyond neglecting a particular rule. We read that it was a calculated display of deceit and insincerity (Acts 5:1-11). Their demise stands as a caution against hypocrisy and the gravity of deceiving the Holy Spirit. However, I believe it would be incorrect to perceive their fate as eternal damnation solely due to that incident. One's salvation hinges on their faith in Jesus Christ, and only God has the insight into the depths of each person's heart.
In Galatians 2:7-9, Paul refers to different "gospels" or messages that were entrusted to him and Peter:
The gospel of the uncircumcision: This refers to the message of salvation primarily directed towards Gentiles, which speaks to the justification by faith apart from the works of the law. This was the gospel that Paul was commissioned to preach to the Gentile nations.
The gospel of the circumcision: This pertains to the message of salvation predominantly aimed at the Jewish people, emphasizing the fulfillment of the promises made to Israel through the Messiah, Jesus Christ. Peter was entrusted with the responsibility of proclaiming this gospel primarily to the Jewish community.
versebyversecommentary says:
when they saw that the gospel for the uncircumcised had been committed
to me,
When the Jerusalem Council recognized that God had committed the
gospel for the Gentiles (the uncircumcised) to Paul, this dropped like
a bombshell on the Judaizers.
The word “committed” means entrusted with, to make a deposit. The
Council entrusted the ministry to the Gentiles to Paul. Paul did not
invent the gospel of grace; God entrusted him with it.
as the gospel for the circumcised was to Peter
The word “as” indicates that Paul was on the same plane of authority
as Peter. Not only did the apostles in Jerusalem vindicate his
message, but also they affirmed his ministry.
The gospel to the uncircumcised and the gospel to the circumcised are
not two different gospels. It is one gospel to two different groups.
There is only a difference in the recipients, not in the gospel of
grace. The gospel does not involve the need for circumcision as a
qualification for salvation. The gospel “for the circumcised” means
Peter’s ministry was primarily to Jews, not Gentiles.
In Romans 11:5-6, Paul is addressing the relationship between grace and works. The key point Paul is making is that grace and works are mutually exclusive when it comes to the issue of salvation. He's not saying that salvation was once by works but now it's not.
We can see this if we use a different translation:
Romans 11:6 NIV
6 And if by grace, then it cannot be based on works; if it were, grace
would no longer be grace.