Games have had cheats in them for a bazillion years. Im sure that at one stage the programmers just put them in by themselves to have a bit of fun (I know I would), but surely now it is mandated by the game producers.
Cheats and Secrets simply make the game more exciting. Thus people enjoy them more, and are more likely to buy a similar game. I dont think you would find many games released nowadays without Cheats.
As to how they are discovered, as a kid I used to think that some lucky person just fluked it and told everyone but the sheer number and complexity of them indicates that the game companies release Cheats themselves.
PS: I am a purist and never use cheats until after completing the games.
E.g. your game company gets a report that the beta version of the game crashes if the player shoots the final boss with an ion cannon. You could have your testers play through the game, start to finish, over and over until they can repeat the bug. Or you could add a “level warp” code and an “all weapons” code and save everyone a lot of time.
A lot of the GTA:VC codes were in fact discovered by people doing random button presses, and relying certain patterns. A couple others were discovered by people using hex editors.
But some other codes remain hidden for years until leaked by the developers. A great example of this is GoldenEye for N64–it had codes that came out years after the games’ release because the developers kept them secret.
All of the above. Plus, after finishing the game, it’s so much fun to be able to try some funky stuff you couldn’t possibly do when the game was trying to kill you. (ie, testing all the weapons everywhere), or adding some new feature, like low-gravity in GTA3. giveusatank
Of course, in some games, the cheat codes are sensical words or phrases, which migh (potentially) be easily guessed. For example, in Hexen, typing “nra” gives you all the weapons, and “casper” lets you walk through walls. And in Starcraft, “power overwhelming” (which is one of the things said by one of the units) turns all your forces invincible.
There are also some codes which are repeated (sometimes with trivial variations) in many games. “xyzzy”, for example, is a cheat code in many computer games (it’s a reference to one of the ancient text-only adventure games). And I think that several Nintendo games used the same cheat as the infinite lives one from Contra. So when a gamer gets a new game, he might try a few of the “old classic” codes to see if they work.