Train travel has not declined unless you're American. It certainly has not in Europe. OK, yes, the UK shut down a lot of lines in the 1960s because they became unprofitable but to get between major cities, it is very much still there, as in the rest of Europe.
You'd only do it on an expensive luxury train like the Orient Express, or the Blue Train in South Africa, or maybe the Ghan in Australia. On those you're paying a small fortune for a luxury trip, dinner is like being in a top restaurant except you're moving, and you dress up for the occasion as you would in a top restaurant. You want to fit in, enjoy that kind of atmosphere, everyone else expects it - dinner suits and nice dresses are the way it should be, at least for dinner. Really you wouldn't be on this kind of train at all except for a special treat and to travel this old-style luxury way.
All those I mentioned are long-distance trains where you're going to be on the train overnight so they need to serve meals and also provide a decent bed.
But if you're just going by normal train from A to B, no. Not even in first class, which isn't what it used to be - all you're likely to get is a bigger seat and more chance of food being served at your seat.