Why do games put in cheat codes?

Originally, cheat codes were tools that helped developers to test the games they were building . For example, a cheat code that jumps you to the end of a game could help developers test the latter parts of a game without needing to play through the entire game first.