When you give a gift to other people, if you list conditions to keeping the gift, is it still a gift?
Let me present you a story:
You're living at home and you're going to high school. Your father comes to you and tells you if you make straight A's on your report card, he will buy you a brand new car, but he tells you the only way you're going to get that car is if you make straight A's. So you work real hard, and you do make straight A's. So you and your dad go to the car dealership, and you give the seller your report card and you say "here's my straight, so I want my car now. He looks down at you, quizzically, confused, slightly amused, and tells you "I can't give you a car with this. You need to pay for it." You tell the dealer "but I got all straight as. I was told that when I got all straight as, I'd be able to get a free car." The Dealer says "I'm sorry, but here, straight A's won't get to the car. You still have to have money in order to buy the car. If you don't have money, then you don't get a car."
Your father comes up, he steps in between you and the dealer. He hands a check of $20,000 to the dealer, and the dealer says "right this way to your brand new car".
Why did the dealer not accept those straight A's?
because all the work you did doesn't mean anything to him. he wont accept that form of payment.
Your father, on the other hand, does have the form of payment and he paid it in full.
Now, you tell me: is that car still a gift?
even though you made straight A's, there's nothing you could have done to have gotten that car on your own. Your father had to give that person a check for $20,000 in order to get that car your father paid that person a debt for that car was erased, and that car became yours.
In the same way of salvation... there is nothing on this earth that we can do on our own to gain it since it is something that Christ only can give, but that does not mean we do nothing once we have it. Like those straight A's on the report card, we have to put in the work to show that the faith we have is indeed real, true, and genuine.
Demons believe, yet they shudder, so it can't just be faith alone, or faith only, otherwise all the demons would be saved. That's the point that James was making in James 2... the point he was trying to make is that works prove faith is real. Even Paul himself said in Ephesians 2:10
"for we are God's workmanship created to do good things beforehand so that we might walk in them. Faith has always been accompanied with works because those works show that our faith is real."
When we walk in our works it shows that the faith we have in Jesus Christ is a real, saving faith. It shows the inward change in our hearts and in our minds that we have made in commitment to the Lord.