Thank you for the question, “Why does the gospel tell us that we must endure trials with joy in James 1:2?”
James 1:21 does not say that believers are to endure trials with joy. James 1:21 says that believers are to view trials with joy. There is a difference between enduring trials and viewing trials with joy.
The trial and crucifixion was not a joyful event for Jesus. He prayed that if it was possible that the cup be taken from him, but not his will but your will be done. Jesus was able to see beyond the cross of suffering to the resurrection and glory to come.
Christians are not sadistic, wanting suffers and trials. No one really wants trials in their life. God knows that believers are unlikely to change on their own. God uses trials to bring about a godly character and godly actions. In verses 3–4, James says “because you know that the testing of your faith develops perseverance. Perseverance must finish its works so that you may be MATURE and COMPLETE, not lacking anything” (NIV).
Believers know and believe that plan of God is to make us more Christ-like in character and in action (Rom. 8:28–29). It’s not being who we want to be but more like Jesus so that the people see Christ in us. For believers know that one day when we see him we shall be like him.
God doesn’t want infants as his children. He wants mature and complete sons or daughters of God. Our spiritual maturity comes by testing what we know and believe so that the truth becomes a reality for ourselves.
SUMMARY: God wants mature sons and daughters, not infants. This maturing process comes through teaching and trials.
For more perspectives:
https://www.quora.com/Why-does-the-gospel-tell-us-that-we-must-endure-trials-with-joy-in-James-1-2