Finding cheats?
The first link above details how to do it for a GBA game but it is much the same whether you are playing on a commodore64, N64 or modern X64 PC (though PC stuff has some additional quirks in some aspects).
Games use memory to store everything the game runs. The everything is the problem so you need a way to search to find things. To this end we have cheat searching tools (the N64 in my case being where I learned originally how to do this properly). The general idea being you get into the game, start a search and it will note the contents of memory, you do an action that hopefully changes the relevant part of memory, then get the cheat search to search through its list of changes since last snapshot to see what changed, you repeat the process again having changed the area once more until the list of changes narrows down to the point where you can try fixing certain locations or writing greater values into it to see what happens.
It gets a bit more involved as you don't have "has changed" search and often will have additional options like greater or smaller/less than before, within this range, specific value search, has not changed (can be useful to eliminate say memory associated with background timers, animations and such like), larger or smaller value ranges (not everything will use a full 64 bit value and so sometimes you might want to do 32 bit, 16 or 8, or indeed maybe even 128).
There are also additional tricks of the trade as it were -- moon jump is more of a flag in the event of double jump, finding hard to change stats usually involves finding an easy to change one and moving sideways until you find the one you care about, end game sword usually involves getting a lot of the starting town weapons and then change values/location depending upon what you see... but basic infinite health and infinite money are done by spending something small/picking up something small and searching for the change, repeat as you will, health as mentioned is not a nice number in this case and instead hearts so might not have the options for specific values but it is still possible to take some minimal damage or stand by somewhere to heal to get enough searches in.