God brought the Israelites into those trials and difficulties in the wilderness to humble them, and let them see what was in their hearts, that they might be convinced of their own perverseness by the many discoveries of it under those temptations, and so that they might be sensible that it was not for their righteousness that God made them his people, and gave them Canaan, seeing it was so evident that they were a stiff-necked people. Deut.8:2, 3. "And thou shalt remember all the way which the Lord thy God led thee these forty years in the wilderness, to humble thee, and to prove thee, to know what was in thine heart, whether thou would keep his commandments, or not.