Stephen Sondheim’s most popular musical turns the world of fairy tales topsy-turvy, reminding us that granted wishes often bring complications.