In Deuteronomy 8:2-10, it is very clear that God tested his people, before he let them go to the promised land.
We may wonder sometimes, why difficult things happen to us. 1 Peter 1:6, 7
But perhaps, we do not realise, as many of the people of Israel did not realise while in the desert, that we are just being tested by God. God wants to test our faith, to see how we will react and what we will do.
If we look carefully in Deuteronomy 8:2-10, we can see that God wanted to find out if his people will keep his commands or not, while in the testing time in the desert. Why did God test them to find out if they will obey him? Did he not know beforehand, if they will obey him, before he tested them. Perhaps he did not. Because if he did, verse 2 would not say that God wanted to find out if they will keep his commands when tested.
So with us, we like all the blessings from God, and we do not think that we should be tested, in order to have blessings from God. But, he thinks differently, and very often, he will pass us through the test of our faith, before he gives us the blessing. It is something we do not like to go through, but he does, and he has a purpose for us, to pass us trough the testing first.