Gameboy games use a CR2025 battery which over the years eventually dies stopping games from saving and causing previously saved games to disappear. Note however while the game is powered you can still save, however once you power down the save will be gone.

In order to replace the battery you must open up the cartridge with a 3.8mm screwdriver security bit. Next you have to carefully pry the connectors loose from the existing battery since the original battery is actually soldered to the connectors. A common method on replacing the battery is to use an adhesive (preferably) electrical tape to hold the new battery in place. It's important to note you do not want to remove or break the current connectors, if you do so you will need to buy a complete kit which requires you to solder new connectors in place.

Once replaced you can continue to save games again, however down the road in 10-20 years you will have to replace the battery again.
To avoid losing your saves forever there are some great resources on actually transferring your existing saves to your PC.