Jesus clearly calls this mysterious occurrence a "vision" (verse 9). It was not reality but a glimpse of what the future held for Jesus Christ.
The word "transfigured" in verse 2 sounds esoteric, but it is merely the passive form of the Greek word metamorphoo, meaning "changed in form" or "transformed." This same word is used in the well-known Romans 12:2, ". . . be transformed by the renewing of your mind. . . ." Unlike Matthew and Mark, Luke uses the phrase egeneto heteron, translated as "was altered" and meaning "became different" (Luke 9:29). In the vision, the three disciples saw Jesus change to the form He will have in God's Kingdom, which He alluded to in Matthew 16:28.
Why did Moses and Elijah appear with Him? This is where the events of Matthew 16 become important. These two servants of God were the most revered among all the Old Testament figures. Moses, the Great Lawgiver, personified the Law, and Elijah, the Archetypal Prophet, the Prophets. Evidently, the vision depicted Moses and Elijah speaking to Jesus in a servant-Master relationship, but the disciples failed to see this vital distinction.
Notice how Peter puts it. "Let's make three tabernacles, one for each of you." The other accounts say he did not really know what he was saying, meaning that he had missed something in his fear, that he spoke without thinking it through (Mark 9:6; Luke 9:33).
What happened as a result of his thoughtless comment? Notice that Matthew writes, "While he was still speaking. . . ." This is a big clue. God, immediately seeing that the disciples did not understand, took steps to make it plain. To paraphrase what God says, "Look! Jesus is MY beloved Son, and He has MY highest approval. Listen to what HE says! He is far greater than Moses and Elijah, the Law and the Prophets."
This is why the transfiguration occurred. God wanted to make it very clear to the disciples that His way of life is based on the life and death and life again of Jesus Christ, not on the Jews' traditional beliefs. He had to stun the disciples so that they would put Jesus and His teachings on a higher level than Judaism—even higher than the teachings of Moses and Elijah.
Whatever Jesus says is far more important to our salvation than the minutiae of Moses' law or the vagaries of prophecy. In many instances, Jesus makes upgrades to Old Testament law, giving a higher, spiritual meaning (for instance, Matthew 5:21-22). Hear Him!