Lohengrin was already established as a legendary character before Wagner came to tell his story in opera.
A Knight drawn from the German Arthurian legends, Lohengrin is a Knight of the Holy Grail and the son of the Grail King Parzival, another fabled figure Wagner wrote music for. In the legend, Lohengrin is sent to defend the honour of the Duchess of Brabant. He can protect her but there is a condition: she must never ask him his name nor question anything about his identity.
The idea of this type of Christian, knightly intervention, and the forbidden nature of knowing anything about it appealed to the German composer and he made it the focal point of his operatic interpretation of the tale.