James is addressing his letter to Jewish Christians scattered outside of Palestine because of persecution and induced dispersion in most cases. These Jews must have been disillusioned and even disheartened and tired. They stood up for their faith! They were faithful to Christ at the risk of losing family ties and friends! Security through their trade was found in their home city(s) along with a sense of oneness and purpose. So why is it they had to flee from their homes out of fear of persecution and death? Wasn’t following Jesus supposed to be a bed of roses? Who is this person to tell us how great it is to be experiencing trials? Not only that, he didn’t put a clause in there telling us if we send him money we would be blessed with prosperity! I am hyperbolizing on this point for effect, but I believe it explains my point.
James is addressing the Diaspora which would refer to people who have been scattered from their ancestral roots. I even like how the New World Encyclopedia says it better because it speaks of people forced or induced to leave. With all of this in mind he is now telling the Diaspora to count it all joy? Not only that James tells them it’s coming, not if, but it is coming! The pep-talk is to rejoice because you will suffer regardless of your faithfulness.
What do you need to rejoice about today in the midst of your suffering? It should not be by surprise this moment would come because even James told us that it was a case of "when", and it was never "if". Hang in there and rejoice while God will reveal his purpose in His time.