What is the origin of elves, fairies, and other similar supernatural beings? This is a difficult question to answer. (This image is from the British Museum, dating to 1792)
One of the reasons why this is the question of origin is difficult to handle is that cultures nearly universally emerge from prehistory with beliefs and stories dealing with a full array of supernatural beings. Finding a point or origin in a prehistoric past is nearly impossible and can only be a matter of speculation.
It is possible, however, to focus on the pre-industrial inheritance of Northern Europe. Medieval Norse literature frequently mentions these sorts of supernatural beings. It is not clear if these entities are identical to what nineteenth-century folklore collectors encountered, but there is enough continuity to suggest that they are either the same or there was cultural drift that at least links the supernatural beings expressed in literature and oral tradition in the two periods. Some of the difference may also be the result of different forms of expression: medieval literate writers as opposed to illiterate nineteenth-century storytellers.
One the peculiar things about a certain type of supernatural beings is that regardless of the term used, they seem to hang together with a great deal of continuity. These are the elves (but we can also refer to them as fairies, sidhe, huldrefolk, or in parts of Scandinavia they are also called trolls). These entities are distinct in the way they are believed to live in communities with societies that roughly reflect the human condition. Outside of Britain, Ireland, Brittany, and Scandinavia (with some bleeding over into continental Europe and Russia), this idea is nearly non-existent.
(This is an illustration of Swedish trolls who have abducted a human infant, by John Bauer, 1917)
Supernatural beings playing the same part in similar legends are usually singular - or appear in pairs or threes - but they act singularly. It is reasonable to ask how this concept existed across linguistic lines in a well-defined geographic zone. If the idea diffused, why did it not diffuse elsewhere? Most folklorists would shun the explanation of diffusion because this perception of elves seems to be such a core perception of the supernatural world that it would be difficult for it move from place to place: when it comes to folklore, stories travel easily, but they usually adapt to local belief systems rather than carry foreign belief systems with them.
(From William Bottrell's 1873 book on Cornish folklore)
So, by way of not answering the question of origin, we can describe this peculiar aspect of oral tradition related to elves, but we cannot say with authority where it originated. The question of origin for all the supernatural beings at the heart of this question is in a remote past that is difficult to describe or understand.
For sources: on trolls, a great piece of work is Elisabeth Hartmann, Die Trollvorstellungen in den Sagen und Märchen der Skandinavischen Völker (Tübingen: Eberhard Karls Universität Tübingen, 1936). In general, one of the most respected authorities on the question of Celtic and Scandinavian folklore is the late Bo Almqvist; see his Viking Ale: Studies on Folklore Contacts between the Northern and the Western Worlds (Aberystwyth: Boethius, 1991) edited by Éilís Ní Dhuibhne and Séamas Ó Catháin. There is also a book released a few months ago, edited by Simon Young and Ceri Houlbrook, Magical Folk: British and Irish Fairies 500 AD to the Present (London: Gibson Square, 2018) - I have a chapter in this volume on Cornish piskies. By way of disclosure, this post is an adaptation of an answer I provided a year ago for reddit's "AskHistorians"