Historians have long investigated the historical origins of the Arthurian legends. The legendswere written in the Middle Ages, about a kingand his court who purportedly ruled England during the century following the departure of the Romans in 410 CE. Obviously, the tales of King Arthur can't be considered completely historically accurate, since they involve fantastical elements like dragons andmagic. But it's possible that the Arthurian legends could have been based on real people. Since solittle written evidence from the 6th century CE survives to the present, we'll never definitively know. But it's much more likely that Arthurian legends from the medieval period are derived from earlieroral and written folklore.
One of the most enigmatic figures from the Arthurian legendsis Merlin, Arthur's wizard, prophet, mentor, adviser, and in some versions, a tragic romantic hero in his own right. Merlin wasn't invented in medieval England. Like King Arthur, he's a combination of several pre-existing legendary figures from British and Welsh folklore, and possibly Scottish and Irish as well. There's even some evidence that Arthur's enchanter was also based on a historical person.
Again, we'll never know for sure. But here are historians' best guesses as to who Merlin was based on, and how the character came into existence.