During a game, your character may find something, like a computer for example, that is password protected, but needs to look at it in the game for some reason. The game will contain an item (like a document) which reveals the actual password.

However, in real life that would be less likely - if there is a document containing the password, it's more likely to be only on the computer itself. To add a bit more realism (even if it's an unrealistic game) they could just hint to the password, through dialogue and things relating to whoever created the password.

For example; it could be mentioned that whoever created the password is "a fan of a book" (it could be real or fictional) and "identifies with a character" - so the player (who hasn't just given up and looked at a walkthrough) will be left to determine that the password must be that character's name, or something. That's just one example.