There are many characters in plays whose names are never mentioned. Formal introductions just get in the way of plot, so unless the audience needs to know that Mr Worthing is Ernest in the town and Jack in the country, the author doesn’t waste time telling them. On the other hand, the director needs to know who plays whom, actors need to know who they are and who says which line. Consequently (in the vast majority of plays) each spoken line is assigned to someone.
Whilst the names of the characters may not matter from the viewpoint of the audience, they make a difference to the rehearsal process and to the readability of the script. Consider a script with four characters:
Some authors will abbreviate these to initials (TM, SM, LM, DM). I dislike that because it looks horrible and it prompts the reader to translate: the director has to go between two levels to get from DM through Disorientated Man to Steve who is playing the role.
Another option is Man 1, Man 2, and so on. This leaves most of the attribution redundant as what distinguishes the characters is not “Man”, but the single trailing digit. Of course, it’s possible to assign lines to the distinguishing adjective – Tall, etc., but this doesn’t always work well (for example in a script with Tall Man and Tall Woman).
My preferred solution is just to give the characters names. Since the names don’t matter, other than for the rehearsal process, it’s down to the whimsy of the author. In A Little Night Music, there is a Greek chorus. They could have been named Baritone, Tenor, Soprano 1, Soprano 2 and Mezzo-Soprano, but Sondheim choose quirky names, calling them Mr. Lindquist, Mr. Erlanson, Mrs. Nordstrom, Mrs. Anderssen and Mrs. Segstrom. Samuel Beckett went for enigmatic: in Waiting for Godot, the script assigns lines to Vladimir and Estragon, but they call each other Didi and Gogo, and at one point Vladimir is addressed as Mr Albert. Tom Stoppard picked an alphabetical system in Dogg’s Hamlet, with Abel, Baker, Charlie, Dogg, Easy and Fox.
So the names don’t matter in themselves, but they can smooth the path to production. Mind you, names don’t always make life easy and there is always the director’s dilemma of whether or not to address the actor by the character’s name. I recently saw a production of Jumpers for Goalposts which included actors called Danni and Daniel, neither of whom were playing the character of Danny.