James gives a two part answer. The first part is in Jam. 1:3 -- "knowing this that the trying of your faith works patience."
The word "knowing" is a participle both in English and in Greek. In both languages, participles are usually subordinate to (dependent upon) the main verb in a sentence. That means that participles give additional information about the main verb.
In this case, the main verb is "count" (ἡγήσασθε) in Jam. 1:2. The participle in v. 3 gives the reason why James is telling his readers to count faith-testing trials all joy: because we know that such trials of our faith produce patience.
As noted previously, the word translated patience (ὑπομονήν) is not the ability to stand in a long checkout line at a Walmart without losing your cool. It is the ability to keep on running the 10k marathon when you hit hills in the 7th kilometer.
But James isn't talking about endurance in general. He certainly isn't talking about physical endurance. He is talking about faith's endurance. Our faith is like a set of muscles that require practice and exercise to build the stamina necessary to endure the rigors of spiritual battle.
God is much like the drill instructor who wisely and appropriately pushes his soldiers to their limits to build their endurance. An officer knows that his soldiers will be worthless in battle without stamina. We too are soldiers (2 Tim. 2:3-4), but we are of no value in Kingdom warfare without enduring faith (Eph. 6:16; Heb. 11:6).
He whose faith in God's wisdom, power, goodness, or faithfulness wavers in the battle is unsteady, unstable, and displeasing to God. "Let not that man think that he shall receive anything from the Lord" (Jam. 1:6-7).
So God intentionally puts us through tests, not primarily to see IF we will believe Him, but rather to strengthen our faith, our confidence in Him. As we come through faith-tests, by His grace, our confidence in God grows firmer and firmer.
Steadfast and immovable faith greatly glorifies God. It magnifies Him as the All-Sufficient, Fully Trustworthy One. His goodness, wisdom, power, and faithfulness shine brightest when His children continue to trust Him in trials that appear to belie His character.
This is the first reason we should rejoice: God is strengthening our faith and glorifying Himself through our trial(s).