Why does James chapter 2 say that 'faith without works is dead'?
If you turn to Romans 4:1-5, you will read of how Abraham believed and he was counted as righteous. If Abraham was justified by his works, he might boast of his own merits. But he has no ground of boasting before God. Therefore he was not justified by works.
The intention of James chapter two is that only he who has faith that has works following is justified.
James calls faith without works dead. He compares a false faith that does not show fruits to being something that is not alive. Dead faith does nothing. You cannot be justified by a faith that is not real. If you believe then there will be evidence. Faith is to be proved by works, and this living faith properly justifies and saves, and works prove its genuineness to be a living faith and not dead.
Devils have a type of faith that believes, but it is not a working faith that serves God. It is a false kind of faith. James is comparing that false faith with true faith that loves God and bears fruit as a consequence.
Works was not the cause of Abraham being justified as Romans 4 denies that, but as an effect of it, showing that his faith is true faith, and that he is justified. He had both faith and works, and we know that he had faith because of his works (when he offered Isaac upon the altar when asked but was stopped as it was just a test of his faith).
Paul focuses on the imputation of righteousness in some of his epistles, and James speaks concerning the manifestation of righteousness by the conduct, and that before men, you are proved to be justified, as it says 'shew me thy faith without thy works, and I will shew thee my faith by my works'.