He would have already known what was in their heart, and if they would kept His commandments.
NKJV - 2 And you shall remember that the LORD your God led you all the way these forty years in the wilderness, to humble you and test you, to know what was in your heart, whether you would keep His commandments or not.
For follow-up discussion and general commentary on the topic. Comments are sorted chronologically.