From Judaism Q&A by Rabbi Avigdor Miiler
Q: Why did Hashem need to test Avraham? Didn’t He already know that Avraham feared Hashem?
A: A test isn’t for Hashem to find something out. He already knows everything. A test is to bring out a person’s potential, and to make him even greater. After Akaidas Yitzchak, Avraham became even greater than he had been before. (Rejoice, O Youth 225)
Q: Why does Hashem need to test us? Doesn’t He already know what we are going to do?
A: Tests serve two purposes: