Canonical information is limited
From the movie we discover Doc's stated reasons.
- He had to retrieve his dog, Einstein.
- He felt compelled to make sure Marty was OK.
The gift of the photograph could have been a reason, but it also could have been nothing more than part of the preparations for an already approved/decided-upon journey.
When Marty asked where Doc Brown was going, "back to the future?" the Doc specifically states that he's not returning to the future. "No, already been there." Curiously, he's already been to the past, too. He doesn't tell us where he's going, but he travels through time to get there. That's the closing scene of the trilogy.
There are potential story writing reasons...
There are a number of potential story writing reasons why the time train exists. None of these reasons have anything to do with the story itself or the world created as the framework of the story.
The time train certainly serves a story purpose by allowing for a western-style epilogue where everybody says their good-byes and the move ends on a distinct up-beat. There can easily be no other reason for the time train than this.
The time train may symbolically represent the idea that the "journey never ends," which is a big deal when it comes to time travel and its many potential ramifications. It's very common for aspects of a story (including its props) to serve symbolic or metaphorical purposes.
Robert Zemeckis may have wanted nothing more than to do one more really cool thing. And I have to admit, it would have been a riot working on the crew that designed and built that train.
Zemeckis may have wanted nothing more than to end the movie the way the first two ended: with an open-ended cliff-hanger. Doc, sailing off into the sunset of time....
Finally, Zemeckis may have wanted nothing more than to end the movie with the signature visualization that had come to represent the entire franchise (and was likely intended to do just that). In this case, the train is nothing more than a way to reflect an 1800s Delorean for a unique movie ending.
But if you're looking for in-world reasons...
But if you're looking for an in-world reason to explain why the time train exists, all I can tell you is that sometimes the quest for answers doesn't prove fruitful. Worse, it's often a huge mistake to insist that every aspect of fiction have an in-world (or, worse, a Real World) explanation.
The several opinions that have been proffered are interesting — but without commentary from Zemeckis and/or his writers, they're just speculation, and pretty wild speculation at that. I have two words for you: prime directive. Showing up in ancient Rome with a time train would cause its own problems with history and it's a bit harder to disguise or hide than a Delorean.
I have a sneaking suspicion that Zemeckis didn't have an in-world reason for the train beyond what Doc Brown said, which was really nothing more than a rationalization to produce the epilogue Zemeckis wanted.
But I'll defer to additional canon, if such can be found.