Dragon Quest III on the NES uses static RAM for saving. The static RAM stores the state of your game, but it requires power. The power is supplied by an on-board battery soldered to the circuit board.
You can see in this image there are two MOSEL branded RAM chips, one of which is used for save games1. The circular object is a CR2032 coin cell that provides power to keep the savegame RAM active while the game is not inside the console and powered on.
It's most likely that this battery has become exhausted with age and is no longer able to power the save RAM. If so, you will need to replace this battery by dismantling the cartridge and substituting another battery of the same type and mounting.
A more involved alternative may to remove the static RAM entirely and replace it with non-volatile FeRAM which is similar but doesn't lose its contents when the system is off, but this relies on you being able to find a substitute that has the same physical layout as the original static RAM (or an adapter daughterboard).
Alternatively, other causes of savegame loss include:
- A badly maintained console communicating with the cartridge improperly - if your console is old it may need recapping or its contacts cleaning.
- Physical shock to the system - if the contacts are dirty, then knocking the system or pulling on controller leads might cause improper communication and savegame corruption.
- Powering off the system during a save - it's best to wait a few seconds after the game has reported that the save has completed, just in case. Also, old Nintendo games sometimes instructed the player to 'hold RESET and turn the power off' when saving for the most reliable save. https://gaming.stackexchange.com/questions/229723/why-is-it-needed-to-hold-reset-when-powering-off-the-nes
- Game bugs - certain sequences of events in the game might cause the save game to be destroyed, e.g. carrying too many different item types. You'll have to look this up for your specific game and just avoid these circumstances. Examples of save game ruining glitches: Donkey Kong Country, Final Fantasy VI.
1 I believe the other RAM chip holds graphics data - RAM is used here instead of ROM to allow it to be rewritten during gameplay for animated tiles or just general ease of programming.