James may be reacting to a garbled understanding of Paul's teaching (that we are 'justified' by grace through faith) on the part of some Jewish Christians out there in Paul's territory. His teaching here has been (wrongly) used by some to defend a doctrine of salvation by works.

James 2:24