The fun comes from roleplaying, assuming a role of a person in the setting who has different perspective and different amount of knowledge than the player.
Sure, but...
Ok, maybe an outside-D&D example will help me get across what I’m trying to express here. Are you familiar at all with the Dragon Age series of video games? CRPGs with a heavy emphasis on characters, roleplaying, and player choices with significant story consequences. One of the most infamous decision points in the first game has you choosing who will become the next king of the Dwarven city of Orzamar. One candidate is presented as power-hungry and corrupt, willing to go to any lengths to become king, and in fact had his own elder brother assassinated so he would be next in line (and if you play as a dwarf noble, you’re the middle child who he framed for the assassination.) But, he is more progressive than the other candidate, who is presented as honorable and kind; an advisor to the previous king, who allegedly named him as his successor on his death bed (though no one else was around to corroborate the story). He is a staunch traditionalist. Now, when you make this decision, you have relatively little information about either candidate, unless you are a dwarf noble.
Most players, on their first time playing, tend to pick the candidate who is presented as more noble. Now, in the epilogue, it is revealed that this candidate ruled pretty incompetently, becoming essentially a puppet for the corrupt noble council, driving Orzamar into further isolation from the surface, and exacerbating the extreme wealth and power inequality in dwarven society. Many players, on a repeat playthrough, want to find out if the other candidate would be a better choice. Choosing differently the second time around is in part based on out of character knowledge. You, the player, know what happens when one candidate is chosen, and want to see the outcome if you choose the other. But choosing the other candidate on a second playthrough can still be a roleplaying decision; you’re still imagining yourself as the character you’ve created, in the fictional scenario, making the decision as you imagine that character would. You’ve just decided to play a character with different values than the one you played the first time, who
would pick the more progressive candidate even if he seems less “honorable.” That decision may have been
motivated by out of character information (I want to see what happens if I pick the other guy), but it is still arrived at through roleplaying (“I’ll play an ends-justify-the-means” anti-hero this time,” or “I’ll play a dwarf noble who forgives her brother this time.”)
Now, to bring this back to D&D, when a player comes in with foreknowledge of the setting, module, or whatever, I trust that even if some of their decisions are motivated by their foreknowledge, they are still arriving at those decisions through roleplaying. They’re still imagining themselves as their characters, making decisions as they imagine their characters would. And frankly, even if they’re not... what’s it to me? As long as they’re working towards the common goal of having fun and creating exciting, memorable stories, I’m not worried about whether or not they’re “really roleplaying.” Different players have fun in different ways, I don’t think it’s my business to judge them as bad roleplayers if they let their own foreknowledge influence their characters’ decisions.
Now some of the fun does indeed come from the players (as opposed to just characters) figuring things out and being surprised. That part of the fun indeed is spoiled by knowing the stuff beforehand, but that cannot be avoided with a replay. Now if some players are playing the module first time, those who have played it before can spoil this sort of fun for the first timers too, unless they're willing to not metagame using their OOC knowledge gained via the first playthrough.
Sure. I think if you’ve got players who want to do a blind playthrough of a module, for whom a significant part of the fun is being genuinely surprised, it’s probably a good idea to either not invite players who have played that module before, or to talk to any players who have and remind them not to spoil any of the surprises for the others.