Answer: Before we answer your question about the sacrifice of Isaac, we need to note an important aspect of God's perfect character. Many times, His motives and reasons for carrying out a particular act (or not doing so) do not correlate with those humans would possess.
Since God is all-powerful and the originator of all knowledge (Isaiah 55:8), His thoughts are far above what we can produce. Concerning the sacrifice of Isaac, we need to be careful not to judge God based on our own standards of right and wrong.
For example, from a strictly human (non-Christian) perspective, the sacrifice of Isaac at the hands of his father likely strikes most people as being unnecessary at best and at worse murder. The reason given Abraham for why he should carry out the death penalty on his son was not as punishment for some grievous sin he committed. Rather, he was simply commanded to take his life as an offering to the Eternal (Genesis 22:2).
Death is man's great enemy (1Corinthians 15:54 - 56) because, from a human point of view, it has a finality to it that we cannot overcome. We tend to find it especially abhorrent when, as it seemed in the case with Isaac, a person's life is cut short by the actions of others. This is one of many reasons why most societies severely punish those who murder and only allowing killing under special circumstances (e.g. war, punishment for certain heinous crimes, etc.).
A test of faith
Genesis 22 delineates the trying of Abraham's faith when he is personally commanded to sacrifice "his only son" Isaac by God (Genesis 22:1 - 2). He is told to carry out the offering on Mount Moriah. As an interesting side note, according to the tradition of the Rabbis, this sacrifice caused the death of Sarah. They believe she died, after Abraham left for Moriah, when she discovered her husband's true intentions. The Bible, however, does not back up this supposition.
Arriving at Mount Moriah where the sacrifice is to take place, Abraham makes all the preparations necessary to offer his son to the Eternal. He makes an altar, binds Isaac, and places him on a pile of wood. As he lifts up the knife in order to take his son's life, an angel appears.
The messenger from God not only stops the death but also reveals to us why the sacrifice was required. Speaking for the Lord, he states, "Do not lay your hand upon the lad . . . for now I know that you fear God, seeing you have not withheld your son, your only son, from Me" (Genesis 22:12).
God needed to know
Though God knows "the end from the beginning" (Isaiah 46:10), this does not mean he knew 100% what Abraham would do in regard to Isaac. He always allows us to make our own choices, which we can change at any time.
Although God knew what Abraham was higher likely to do, he still needed to test him to discover whether or not he would follow through and obey him in spite of his love for his only son. All this foreshadows the selfless act the Father would do, roughly two thousand years later, when he willingly chose to offer up his only Son, Jesus Christ, as a sinless sacrifice because of his awesome love for us.
Abraham had the faith to sacrifice Isaac, if needed, because he understood that God had the power to resurrect him from the dead (Hebrews 11:19). All the great blessings that would befall his descendants, and the entire world, were made possible by this outstanding demonstration of faith (Genesis 22:17 - 18).