I missed a few things when I saw this question earlier, so hopefully this is a better answer.
why do they even exist
Some people think hacking singleplayer games is fine and doesn't hurt anyone, especially when you've already bought the game and paid the developers. Some people think a competitive battle's winner should be whoever makes the best teams or uses the best moves in battle, not whoever has time to breed for perfect IVs and hidden powers. Wolfey made a video about hacking in competitive Pokemon.
Hacked normally means corruption to save data.
Different computer applications store their data differently, and depending on how it's stored, it's sometimes possible to figure out how you need to change the data to get the applications to do what you want. Like if you make cookies and people want you to make crunchier cookies, they can teleport you to a different house that's exactly like yours but the cookie recipe on the bookshelf uses a higher oven temperature. Many computers and applications encrypt their stuff (so it's difficult to figure out how to modify it without corrupting) or hash their stuff (so they can detect hacks and corruptions), but Nintendo consoles are known for historically having pretty bad security.
source: I've done programming.
useless fact: Undertale's saves are stored in plain text files, so you can hack Undertale using Notepad.