Even before the start of the reconstruction program, the Reichsbahn began procuring new freight locomotives to replace outdated Länderbahn locomotives and worn-out war locomotives. What was required was a machine with an axle load of not much more than 15 tonnes that could be used universally. Since it was not possible to procure the Czechoslovak class 556.0 due to political problems, a new machine was developed on the basis of the class 50. Care was taken to use as many identical parts as possible with the class 2310 built at the same time.
In terms of frame dimensions, the class 5040 was almost identical to the classes 50 and 52. As with the war locomotives, a plate frame was used, which was too weak for the strains which were posed upon them later. The boiler was a new design with a combustion chamber and mixing preheater, which had about 150 hp more than that of the class 50. This was later also used on the classes 5035, 5830 and 5280. Trofimoff valves were used for better idling characteristics.
Originally, the procurement of 350 locomotives was planned. However, production was discontinued in December 1960 after only 88 locomotives had been completed, presumably because of the reconstructed locomotives. Road number 50 4088 was the last standard-gauge steam locomotive to be newly built in Germany. As early as 1968, the class 5040 was only in use in the area of the Reichsbahn division in Schwerin. It was not until 1980 that the last one was retired. Road number 50 4073 in Nördlingen is the only machine that has survived to this day. It is being rebuilt since 2016, has been in the Meiningen steam locomotive works since June 2022 and could be operational again as early as 2023. Road number 50 4088 should also have been preserved, but this had to be abandoned after an accident.