There is a possibility that Dark Link actually may have come from the Corrupted Sanctuary, or Sacred Realm.
If we have a look at the Timeline, Ocarina of Time is the First Chronological appearance of Dark Link. Sure, this event seems out of place. Dark Link appears in the Water Temple, in a random room (probably one of the saving graces of that entire place). Doesn't really make sense. But thinking about it - When Link drew the Master Sword, His soul was sealed in the Sacred Realm.
In that time, Ganon also took control of the Sacred Realm. His corruptive influence could very well have created a "corrupt" version of Link as well, while his soul was floating around in that evil place.
This would explain why he is found in later games - Link to the Past, Four Swords Adventures, and Spirit Tracks, for example, but not in any previous editions - Skyward Sword, Minish Cap, and Four Swords.
To further support this, this article, which speculates on Dark Link's origins, breaks down the orginal Japanese titles for some of the in-game names:
In Adventure of Link and Ocarina of Time the world from which the monsters come is called Makai in the original Japanese. This is a portmanteau of the words Maou, meaning demon king or devil, and Sekai, meaning world. Makai therefore roughly translates to Demon World: specifically one in possession of a Maou to be in charge and often a Mazoku: a tribe or army of lesser evil who inhabit the world. In Ocarina of Time it is stated that the role of Maou is fulfilled by Ganondorf as Daimaou (Great Demon King) and that the location of the Makai is the corrupted Sacred Realm.
At this point, the mechanics of the game can also be speculated on, looking at Dark Link in OoT, he acts as an almost literal copy of Link, copying your moves, parrying with his own sword, and can only be hit with a weapon that he cannot mirror (like the Megaton Hammer or the Biggoron Sword). In later editions, he acts more independently - as if he has learned, and grown since this first encounter.
So, we have a possible idea of how he came about. As for what he is, well, his appearances in other games might lead into that.
In a few other games, Dark Link is actually called "Shadow Link". In several games he actually appears from the shadows, and even directly from Link's shadow, like in the Adventure of Link. In Oracle of Ages, he (or multiple copies of him) are summoned by Veran - the self-professed "Sorceress of Shadow", and in Twilight Princess, Midna will often hide in Link's Shadow as well, similar to the way that Dark Link did in Adventure of Link. All this points to the possibility that Dark Link, created from the Corruption of the Sacred Realm, using Link's Soul as a template, is a Shadow Creature.
Now, as for Dark Link's purpose.
In OoT, his appearance is random. There is no trigger, and his appearance is out of place. It is very likely that this is simply the Copy, lost and looking for answers, drawn to the Original. But in future editions, he is often summoned by others, as a form of test. Over the ages, Dark Link has grown; developed. Fighting oneself can serve many purposes - as a metaphorical obstacle of one's dark side, or a purifying act of one's soul in order to claim the power of the Triforce.
All of this, unfortunately, however is all speculation.