Bettas don't get lonely. They can happily live a solitary life.
I agree that water quality is very probably the issue. Too cold, most likely, or not clean enough.
I disagree, however, that they can't get bored or depressed. Fish are instinctive creatures, and if you frustrate that instinct long enough, they can suffer - sure they don't feel what we feel, but they do suffer the effects of a non-stimulating, insecure-feeling environment.
Betta splendens don't school or shoal, so they don't care about being alone. They are aggressively territorial so providing them with some plants to hide in will create less stress.
Being predatory fish, they usually have to hunt thier food. Providing some live food he has to chase (mosquito larvae, live brine shrimp) now and then gives that instinct a chance to manifest - and they love it!
Plus all the suggestions above - but first look at your water/temperature.