James 2:21
"Was not our father Abraham considered righteous for what he did when he offered his son Isaac on the altar?"
Abraham was counted righteous before God prior to Isaac's birth. The offering of Isaac was merely a justification of Abraham's faith. Abraham's faith had already previously justified him before God, however. Scripture is clear in this.
Genesis 15:4 "And, behold, the word of the Lord came unto him, saying, This shall not be thine heir; but he that shall come forth out of thine own bowels shall be thine heir.
5 And he brought him forth abroad, and said, Look now toward heaven, and tell the stars, if thou be able to number them: and he said unto him, So shall thy seed be.
6 And he believed in the Lord; and he counted it to him for righteousness."
James is indeed speaking of justification, but Romans 4:2-3 is clear that Abraham's works did not justify him before God. So in who's eyes does works justify a man? Before the eyes of other men.
James 2:18 "Yea, a man may say, Thou hast faith, and I have works: shew me thy faith without thy works, and I will shew thee my faith by my works." This is a conversation between two men, one with works, one without. Both have faith, but only one can prove their faith by their works.
This is a core biblical truth, in which men judge the outward appearance, and God judges the heart. 1 Samuel 16:7 "But the LORD said unto Samuel, Look not on his countenance, or on the height of his stature; because I have refused him: for the LORD seeth not as man seeth; for man looketh on the outward appearance, but the LORD looketh on the heart."
Romans 4:2-5 "For if Abraham were justified by works, he hath whereof to glory;
but not before God. (This proves that the justification in James of Abraham is not of God, but of men). For what saith the scripture? Abraham believed God, and it was counted unto him for righteousness (in Genesis 15, before Isaac's birth). Now to him that worketh is the reward not reckoned of grace, but of debt. But to him that worketh not, but believeth on him that justifieth the ungodly, his faith is counted for righteousness. (That is, faith in Christ according to Romans 5:1-2)."