The word demesne seems to just be an alternative spelling of the rather more logically-spelt domain. I'm wondering how this strange spelling came about? Even taking into account its given etymology from the Old French demein, how did the letter "s" get in there?
This question is too basic; it can be definitively and permanently answered by a single link to a standard internet reference source designed specifically to find that type of information. If this question can be reworded to fit the rules in the help center, please edit the question.
OED has this in its etymology (this is an extract):
The Anglo-Norman spelling demesne of the law-books, and 17th cent. legal antiquaries, was partly merely graphic (the quiescence of original s before a consonant leading to the insertion of a non-etymological s to indicate a long vowel), as in mesne = Old French meien, meen, mean, modern French moyen; partly perhaps influenced by association with mesne itself, in ‘mesne lord’, or with mesnie < mansionāta house, household establishment. Demesne land was apparently viewed by some as terra mansionatica, land attached to the mansion or supporting the owner and his household. Perhaps also Bracton's words [below] gave the notion that the word has some connection with mensa.
[c1250 Bracton iv. iii. ix. §5 Est autem Dominicum, quod quis habet ad mensam suam & proprie, sicut sunt Bordlands Anglice. Item dicitur Dominicum Villenagium, quod traditur villanis, quod quis tempestivè & intempestivè sumere possit pro voluntate sua & revocare.]
So: a long vowel (the second e) was indicated in spelling by inserting an s.
OED does use the word "Perhaps", but it does seem to me to be a bit far-fetched to think that people confused mensa and mesne.
c.1300, demeyne (modern spelling by late 15c.), [snip] Old French demaine "land held for a lord's own use," from Latin dominicus "belonging to a master," [snip] Re-spelled by Anglo-French legal scribes under influence of Old French mesnie "household" (and the concept of a demesne as "land attached to a mansion") and their fondness for inserting -s- before -n-. [snip]