Hashem tested Avraham in order to evaluate the extent of his faith. Before the trial, Hashem did not know whether or not Avraham would be willing to sacrifice his son for God.
Meaning of "נסיון" – Ralbag understand the word to mean "test", a procedure established for purposes of evaluation. Hashem was testing Avraham so as to discern his level of fear and obedience.
Hashem's knowledge – According to Ralbag, Hashem's knowledge is not complete. While He knows all the choices open to man He does not know which man will choose to do. As such, He did not know in advance whether or not Avraham would acquiesce to sacrifice his child upon Hashem's demand.1
עַתָּה יָדַעְתִּי כִּי יְרֵא אֱלֹהִים אַתָּה – Ralbag is able to explain this verse according to its simple sense; only "now," after the trial, did Hashem know how God-fearing Avraham was.
The test – Ralbag asserts that Hashem intentionally worded His demand ambiguously so that it could be understood in one of two ways: to sacrifice Yitzchak as an Olah offering, or to take Yitzchak in order to sacrifice an Olah, and thereby be educated in the worship of Hashem. Since the second reading is one which a person would only hear if they found the first reading objectionable, Hashem wanted to see if Avraham was so willing to abide by Hashem's word that he would not even seek out the alternative reading.2
How can Hashem command murder? According to Ralbag, Hashem had never intended for Avraham to actually sacrifice Yitzchak, which is why He worded the command in a way which allowed for the second (and the ultimately correct) understanding that Yitzchak was brought to the mountain only to witness and learn about an Olah offering.
Avraham's feelings
Can Hashem change His mind?
For Avraham
Avraham, rather than Hashem, was supposed to learn something new from the experience. This position subdivides regarding whether it views the test as beneficial or punitive in nature:
Means to Reward Avraham
Acting on Hashem's directives brought Avraham to new levels of faith, and merited him rewards that he would never have received had Hashem not tested him.
The trial was intended for outsiders so that they appreciate Hashem's choice of Avraham, and understand what is the correct and desired service of Hashem.