The railroad was built in the early 20th century, during the great era of railroad-building around the world. The official Tanzanian railroad web page states,
"Construction of the 86.08 km Moshi-Arusha railway extension of the Tanga Line starting at Moshi in 1911 and reaching Arusha in 1929. The railway distance from Arusha to Tanga and Dar es Salaam is 437km and 644km respectively."
My guide, Morris, said the railroad was built by the Germans. He was partly correct because while the Germans were forced out of their African colonies in World War I, they certainly began the construction project when Tanzania was part of German East Africa. According to Wikipedia, Germany controlled this part of east Africa from the 1880s to 1919, when, under the League of Nations, it became a British mandate.