Over the years the vast majority of our cheat codes have been there as debugging aids.
There are a small number of cheat codes added as marketing tools.
Most of the debugging tools are disabled in production builds. They are disabled not only because they tend to break gameplay, they can break major pieces of the game. A cheat code to jump you to a spot in the story might leave you without critical items; that isn't a problem because in development the person could also use a code to give them those items.
The development team needs to decide about cheat codes to leave in. If they decide to leave the codes in they need to be fully tested. They cannot break any part of the game when they are applied. They need to be fully functioning like any other part of the game.
That includes testing to make sure it doesn't accidentally break multiplayer games, make sure it doesn't break any online reporting or high scores, and make sure any changes it makes to the game only affect local single player functionality. All of that requires design, it requires more development work, it requires extensive testing.
That leads directly to the answer of your final question:
how come they aren't really part of gaming anymore?
Because they have a high cost, particularly the cost of ensuring it does not break any other aspect of the game.
Would you prefer a cheat code that does some small thing for a small number of players, or would you rather have a big feature that can be shown to the world?
Sometimes game features will be fully tested over the course of the game. Unlimited health packs for local gameplay is easy enough to implement and for many people in QA to constantly verify.
Other times someone pays the team to put it in. When Toys R Us offers a studio a small pile of money to add a giraffe as unlockable content, that pile of money and the guarantee of marketing far outweighs the dev costs to build the model and add the code.
Still other times, the development team has a little time where a modeler or other person has a few days of dead time, they may ask their lead if they could throw in a small detail as part of a series of a running theme. In one of our products the forums were constantly talking about a mysterious figure that kept showing up in the game. A shadow over here with red shoes visible; a small room you can peek in but only see red shoes of a figure lying in a bed; one red shoe found inside a dumpster clearly used for someone's housing. The first of these were added during a week a modeler had nothing interesting to do, and the few instances of them in the game sparked quite a lot of interest.
But in all cases, these required manager approval and required work from QA to ensure they worked as needed, never breaking the game.
In most companies, adding in an undocumented Easter Egg -- that is, a feature that the designers and producers don't know about and that QA did not test and validate -- is an fireable offence.