Hi Deidre,
James chapter 2 is about the importance of works to prove one's faith. It's about not showing partiality because God is impartial with us. He doesn't make distinction between rich and poor, as highlighted in James 2:1-4. In James 2:8 he urges Christians to love their neighbors like themselves. If we want to obey God's law and do His will, we have to display neighborly love—being equally loving toward rich and poor. In that sense, showing favoritism towards a particular group of people, would be considered a sin. If we unmercifully show favoritism, we are lawbreakers and that means we become offenders against God’s law.
If you keep reading the chapter, James 2:14-26 talks about how faith produces other fine works. James is talking about works motivated, not by a law code, but by faith and love, that will motivate us to give to those in need. In 16 and 17 James asks: "If you tell a needy brother: “Go in peace, keep warm and well fed” but do not provide the necessities, of what benefit is that? So, too, faith by itself, without works, is dead."