The reason they were there was to represent the water and the blood.
Elijah, the water, and Moses, the blood.They were standing along with Jesus as The Two Witnesses.Which are the covenants.
So on Mount Tabor you have the Spirit(Jesus) water(Elijah) and blood. (Moses)
The first shall be last,and the last first.
Moses(blood) was before Elijah.(water) Get it?
Matthew 17:5
While he yet spake, behold, a bright cloud overshadowed them: and behold a voice out of the cloud, which said, This is my beloved Son, in whom I am well pleased; hear ye him.
Revelation 19:10
And I fell at his feet to worship him. And he said unto me, See thou do it not: I am thy fellowservant, and of thy brethren that have the testimony of Jesus: worship God: for the testimony of Jesus is the spirit of prophecy.
Some people say "so and so are the Two Witnesses because they represent the Law and the Prophets"
At the end of that road it all leads to his covenants.His Two Witnesses.They were there at the transfiguration of Jesus.And will be there at the transfiguration of the 144,000.Who will give the testimony of The Two Witnesses.And those who hear,and believe will be transfigured.