Right off the bat, you are unfortunately not changing the water enough. One gallon containers are so small that they really should have 100% water changes every other day. This sounds ridiculous, but fish constantly excrete ammonia through their gills as they breathe. This is sort of like the fish's means of urination. This ammonia quickly builds up and is very toxic--ammonia is often what you smell when you spray glass cleaner and other cleaning products. It's corrosive and very unpleasant. It is likely what is making your betta sick. Bettas are hardy fish compared to a lot of species on the market, but eventually all this ammonia exposure was bound to catch up to him and you are probably seeing the results of his organs being overworked and his gills being damaged for two years, and his immune system is going downhill.
Filling out this form will help us pinpoint any other possible causes for his problems and solutions for them:
http://www.bettafish.com/showthread.php?t=49233
For now, though, definitely get on board with doing frequent 100% water changes. If you can find it, methylene blue can be helpful to fish suffering from ammonia poisoning and it will help prevent him from catching a secondary infection while in this vulnerable state.