Cheat codes were included in most games as testing tools, making it easy for developers to test game functions without being bothered by game mechanics (invincible, unlimited money, unlock all), because testing the game also means compiling it first, and that takes ages.
Compiling the game including cheat codes allowed developers to test things out while also hiding the codes (they need to make it hard to activate cheats by mistake, because cheat codes are meant to stay in the game even after release).
Nowadays developers have the option to compile the game with or without console access, and from there they can temporarily create their own cheats, by inputting console commands, while keeping the console inaccessible for the final release.
Some games like GTA 5 still include classic cheat codes, not for testing purposes, but as common secrets.
Latest Answers