Matthew, Mark, and Luke each record an account of the transfiguration of Jesus (Matthew 17:1-9; Mark 9:2-10; Luke 9:28-36). Notice Christ's instructions to the disciples as they descended the mountain: "Tell the vision to no one" (Matthew 17:9). A vision is not a material reality; it is a supernatural scene observed in the "mind's eye."
Moses was dead and buried long before this event (Deuteronomy 34:5-6), as was Elijah. The disciples saw these men only in the glory of the resurrection—an event which will not actually occur until the Second Coming of Christ (Hebrews 11:39; I Corinthians 15:51-52; I Thessalonians 4:13-17). So, the three disciples seeing Moses and Elijah in the transfiguration did not see ghosts or spirit beings of any kind but a vision of how they would look—glorified—in the resurrection.
The account of the transfiguration in Matthew 17 also explains Matthew 16:28: "Assuredly, I say to you, there are some standing here who shall not taste of death till they see the Son of man coming in His kingdom." Since God's Kingdom has not yet been established here on earth and the disciples all died, the obvious meaning is that some of the disciples were to be shown the splendor of the Kingdom in a vision. And so they were, through the transfiguration.