I think the Mysterious Figure is a shapeshifter.
KH:3D has Xehanort's Heartless, Xemnas, Vanitas, a young version of Master Xehanort, and possibly the Riku Replica. From my understanding, the main point of KH:3D is to train Sora and Riku to become certified Keyblade Masters. Their efforts in the Realm of Sleep presumably serve a meaningful function beyond just training, but it should be noted that their main reason for their journey in KH:3D is to prepare the Keyblade wielders for enemies they must face in the future. Yet, it seems a bit out of place for Sora and Riku to be facing such dangerous threats. They're essentially up against the league of ultimate KH villains, which seems a bit too much to be put up against without having properly concluded their training.
And the biggest issue is that not a single KH villain has an "apparent" reason for why they would appear in the Realm of Sleep. Xehanort's Heartless and Xemnas were both eliminated in previous games. Yensid suggested that the two of them reunited upon their destruction, thus bringing about the return of Xehanort, so neither of those incarnations of Xehanort should exist separately anymore. Also, the young version of Master Xehanort is literally a thing of the past, since Master Xehanort aged into an old man. If Master Xehanort could reverse the aging process, his possession of Terra would have been pointless. It's unclear of what became of Vanitas and the Riku Replica once they were defeated, but their emergence in the Realm of Sleep would lack an obvious explanation as well.
(That is not to say that it is impossible for the real versions of these characters to exist in the Realm of Sleep, but their circumstances for appearing there would doubtlessly be very different and very complicated... and this series doesn't need anymore overly convoluted explanations.)
I think the Mysterious Figure is an unknown entity that exists beyond time. I think the aim of this timeless entity is to prepare Keyblade wielders for the very real challenges that they will face in the near or distant future. The Realm of Sleep presumably exists in a space between light and darkness, so perhaps this entity can only appear on neutral ground, which may be why it could briefly appear in the Land of Departure. I think the Mysterious Figure is using the forms of former villains to prepare Sora and Riku for their showdown with the real Xehanort and his dangerous allies.
Perhaps once Sora and Riku prove their strength at the end of the game, the Mysterious Figure might use its power over time to show them a vision of the original Keyblade War to warn them about the dangers that exist if the real Master Xehanort succeeds in his ambitions.