11:1 I ask, then, has God rejected his people? By no means! For I myself am an Israelite, a descendant of Abraham,  a member of the tribe of Benjamin. 2 God has not rejected his people whom he foreknew. Do you not know what the Scripture says of Elijah, how he appeals to God against Israel? 3 “Lord, they have killed your prophets, they have demolished your altars, and I alone am left, and they seek my life.” 4 But what is God's reply to him? “I have kept for myself seven thousand men who have not bowed the knee to Baal.” 5 So too at the present time there is a remnant, chosen by grace. 6 But if it is by grace, it is no longer on the basis of works; otherwise grace would no longer be grace.
7 What then? Israel failed to obtain what it was seeking. The elect obtained it, but the rest were hardened, 8 as it is written,
“God gave them a spirit of stupor,
eyes that would not see
and ears that would not hear,
down to this very day.”
9 And David says,
“Let their table become a snare and a trap,
a stumbling block and a retribution for them;
10 let their eyes be darkened so that they cannot see,
and bend their backs forever.”
11 So I ask, did they stumble in order that they might fall? By no means! Rather through their trespass salvation has come to the Gentiles, so as to make Israel jealous. 12 Now if their trespass means riches for the world, and if their failure means riches for the Gentiles, how much more will their full inclusion  mean! (Romans 11:1-12 (ESV)
“But if it is by grace, then it is no longer on the basis of works. Otherwise grace would no longer be grace.”
So Paul points to the problem, what the Jews strive for with works is given to the gentiles, and the remnant of the Jews by grace. If salvation is to be obtained it is to be obtained by grace that is as a gift. And if you work for the gift, it will be taken from you and given to another. Work for a gift? Who does that? It’s actually fairly common when it comes to the gift of salvation, and thus we lose it.
At times, accepting a gift is a humiliating experience. Some people call it “taking charity,” and they are too proud to take charity. What Paul here exposes as the problem for Israel, is all too often our problem even as Christians that no better. Paul here is showing how God remains true to his promises to Israel, and what that will finally mean for the whole world. If there rejection means riches for the world, their inclusion will mean so much more! But they will be included in the same way the gentiles are included, by grace and not by works. So to obtain salvation, to receive the gift a person has to despair of works.
It isn’t that they can’t do works, to that topic Paul will turn momentarily, but the works cannot be done with the purpose of pacifying God, or trying to earn his good graces. To approach works in such a manner as that is to create an idol, it is to trust in the work rather than the gift. It is one or the other, a man cannot have two masters. But the grace of God inspires us to work for his kingdom, inspires us with joy, and this sort of thing radically changes the nature of the work to be done, as well as the attitude with which it is approached. And then we rejoice because God uses even our failures for his purposes, even as he used the failure of the Israelites to bring salvation to the gentiles. This is a God who turns the whole world upside down.