I believe I can actually answer this. First off, I just would like to say that I actually think the ending to the play is much more to my liking than the musical, which feels very mechanical and cliche. The ending with the Masked Man is much more...I dunno, I guess dramatic, because with the Play, Melchior has to choose between his best friend and death, or a complete stranger, who offers him life.
The way it plays out at the end, onstage, is Melchior runs into the graveyard, looking back and worrying that the boys from the Reformatory are going to catch up with him. He then begins searching for Moritz's grave, and stumbles upon Wendla's fresh one. In the play, he's very aware that he raped Wendla...and he feels a lot more angst and sorrow about it than shown in the musical. He cries over her grave, but makes the decision to leave the graveyard. Moritz appears and holds him back. Melchior can't believe what's happening. Moritz tells him all the wonders of death, how you can look at the troubles of the living and laugh. While Melchior is hesitant, he seems ready to accept the offer, reaching out to take Moritz's hand. The Masked Man appears and accuses Moritz of lying and deceit. Moritz admits he was exaggerating and is lonely and wants Melchior to be back with him. The Masked Man preaches the differences between Melchior and Moritz, and reveals to Melchior that while he impregnated Wendla, he did not cause her death - it was the abortion pills. Melchior debated briefly, and in the end chooses life, saying, "Farewell, Moritz. I don't know where this person is taking me...but he is a person." End of play.
I dunno, I like this ending, although obviously it leaves the audience very confused as to who the Masked Man is, but I think the paradox of Melchior's choice is all that matters, and that's lost in translation to the musical, which is a much cleaner ending.
"But alone is alone...not alive..."