Among the Wisdom of Jihad is to test the Muslims
Allah said,
أم حسبتم
Do you think,
O believers that We will leave you untested with matters that make apparent those who have pure, good intent from those who have false intent
أن تتركوا
that you shall be left alone,
This is why Allah said next,
ولما يعلم الله الذين جاهدوا منكم ولم يتخذوا من دون الله وﻻ رسوله وﻻ المومنين وليجة
while Allah has not yet tested those among you who have striven hard and fought and have not taken Walijah besides Allah and His Messenger, and the believers...,
meaning, supporters and confidants. Rather, they are sincere for Allah and His Messenger inwardly and outwardly.
Allah also said;
الم
أحسب الناس أن يتركوا أن يقولوا آمنا وهم ﻻ يفتنون
ولقد فتنا الذين من قبلهم فليعلمن الله الذين صدقوا وليعلمن الكاذبين
Alif-Lam-Mim.
Do people think that they will be left alone because they say: "We believe,'' and will not be tested.
And We indeed tested those who were before them. And Allah will certainly make known those who are true, and will certainly make known those who are liars... (29:1-3)
أم حسبتم أن تدخلوا الجنة ولما يعلم الله الذين جهدوا منكم ويعلم الصبرين
Do you think that you will enter Paradise before Allah tests those of you who fought (in His cause) and (also) tests those who are patient. (3:142)
and,
ما كان الله ليذر المومنين على ما أنتم عليه حتى يميز الخبيث من الطيب
Allah will not leave the believers in the state in which you are now, until He distinguishes the wicked from the good. (3:179)
In summary, since Allah legislated Jihad for His servants, He explained that the wisdom behind doing so includes testing His servants, distinguishing between those who obey Him and those who disobey Him.
والله خبير بما تعملون
Allah is well-acquainted with what you do.
Allah, the Exalted, is the All-Knower of what occurred, what will occur, and the true essence of what might occur had He decided it. Therefore, Allah knows everything before it occurs and how it will occur, there is no deity worthy of worship except Him, nor a Lord except Him. Truly, there is none who can avert Allah's judgment and decision