They can work, easily, if the characters are witting of the allusions and what they mean. Or logically would be, if the narrator uses them. Also if the world is a far-future, or not so far future, setting where we can logically see how the allusion would pass through history, even if the characters no longer recognize them.
And, of course, if the setting is comic. They can positively aid there, because a certain aura of unreality helps us ignore any pain in the imaginary world, and if a poet in an Arabian Nights setting starts to quote Shakespeare, we know he's unreal.
That's the danger in allusions that do not make sense in the fictional universe. It makes the world unreal, or at least touches the world with unreality. It doesn't even work well as comic relief, because once the world is unreal, the serious parts are hard to take seriously, because they aren't real.
Not that it's the only comic technique which can easily undermine dramatic plots. . . .