Can't see what relevance of James 2 concerning eternal security.
It has nothing to do with it at all.
The whole chapter is based on personal favoritism.
That being how the rich were treating the poor.
James 2:1-4
Beware of Personal Favoritism
1 My brethren, do not hold the faith of our Lord Jesus Christ, the Lord of glory, with partiality. 2 For if there should come into your assembly a man with gold rings, in fine apparel, and there should also come in a poor man in filthy clothes, 3 and you pay attention to the one wearing the fine clothes and say to him, “You sit here in a good place,” and say to the poor man, “You stand there,” or, “Sit here at my footstool,” 4 have you not shown partiality among yourselves, and become judges with evil thoughts?
James 2:8-9
8 If you really fulfill the royal law according to the Scripture, “You shall love your neighbor as yourself,” you do well; 9 but if you show partiality, you commit sin, and are convicted by the law as transgressors.
V8 States that if you really fulfill the royal law you do well but if you don't you commit sin.
The royal being loveing your neighbor.
V9 concerning the law.
Leviticus 19:15-18
15 ‘You shall do no injustice in judgment. You shall not be partial to the poor, nor honor the person of the mighty. In righteousness you shall judge your neighbor. 16 You shall not go about as a talebearer among your people; nor shall you take a stand against the life of your neighbor: I am the Lord.
17 You shall not hate your brother in your heart. You shall surely rebuke your neighbor, and not bear sin because of him. 18 You shall not take vengeance, nor bear any grudge against the children of your people, but you shall love your neighbor as yourself: I am the Lord.
With regards to Abraham.
James 2:21-24
21 Was not Abraham our father justified by works when he offered Isaac his son on the altar? 22 Do you see that faith was working together with his works, and by works faith was made perfect? 23 And the Scripture was fulfilled which says, “Abraham believed God, and it was accounted to him for righteousness.” And he was called the friend of God. 24 You see then that a man is justified by works, and not by faith only.
Was he justified when offering Isaac?
Yes he was but did it declare him as being righteous?
No it did not.
Genesis 15:5-6
5 Then He brought him outside and said, “Look now toward heaven, and count the stars if you are able to number them.” And He said to him, “So shall your descendants be.”
6 And he believed in the Lord, and He accounted it to him for righteousness.
He believed this, it was his faith that declared him righteous and Isaac wasn't even born then.
Now if we want to look at actions or works that justify Abraham is it this
Genesis 15:7-11
7 Then He said to him, “I am the Lord, who brought you out of Ur of the Chaldeans, to give you this land to inherit it.”
8 And he said, “Lord God, how shall I know that I will inherit it?”
9 So He said to him, “Bring Me a three-year-old heifer, a three-year-old female goat, a three-year-old ram, a turtledove, and a young pigeon.” 10 Then he brought all these to Him and cut them in two, down the middle, and placed each piece opposite the other; but he did not cut the birds in two. 11 And when the vultures came down on the carcasses, Abram drove them away.
Firstly notice what God said to Abram.
He bought him out of Ur.
One day Abram is going around his business he hears God to leave his life in Ur to a land Abram knew nothing about.
Yet he went.
It was out of faith he did so.
Isaac was not born then.
So Abraham was not justified by offering Isaac but in doing so because of his faith his faith was justified by doing so.
This is what James is saying.
And here is the precursor
James 2:14-17
Faith Without Works Is Dead
(cf. Gen. 22; Josh. 2)
14 What does it profit, my brethren, if someone says he has faith but does not have works? Can faith save him? 15 If a brother or sister is naked and destitute of daily food, 16 and one of you says to them, “Depart in peace, be warmed and filled,” but you do not give them the things which are needed for the body, what does it profit? 17 Thus also faith by itself, if it does not have works, is dead.
Let's look at what Jesus said.
Matthew 25:35-36
35 for I was hungry and you gave Me food; I was thirsty and you gave Me drink; I was a stranger and you took Me in; 36 I was naked and you clothed Me; I was sick and you visited Me; I was in prison and you came to Me.’
We see thirsty, naked, stranger .
Who was he talking to?
Matthew 25:37-40
37 “Then the righteous will answer Him, saying, ‘Lord, when did we see You hungry and feed You, or thirsty and give You drink? 38 When did we see You a stranger and take You in, or naked and clothe You? 39 Or when did we see You sick, or in prison, and come to You?’ 40 And the King will answer and say to them, ‘Assuredly, I say to you, inasmuch as you did it to one of the least of these My brethren, you did it to Me.’
So these people, the righteous people were justified by what?
Their works before men.
We are declared righteous by faith and as a result works will follow.