JasonC3 said: "The one thing we definitely know they often do is generate a quick hit of free media exposure which, in turn, might sell some seats."
Yeah, a few weeks ago I saw The Sign in Sidney Brustein's Window and Rita Moreno, who was in the original Broadway cast, was in the audience. The press had been tipped off she'd be coming and the next day photos or video of her speaking onstage during the curtain call appeared in Page Six, Town & Country Magazine, and all the Broadway related publications.
Also, I wasn't there for this but Nicole Kidman bid $100K at a charity auction Hugh Jackman was doing after a performance of The Music Man and that went viral.
If there's some performative element to the celebrity appearance, it can help raise awareness around a show. If it's literally just someone famous was in the audience and stayed in the audience, that's probably not going to move the needle.