For Cars, Trucks, Buses, Trains, and even Ships, the main engineering requirement is that they all need a certain torque at a certain speed at a given instant of time. The Petrol or Diesel Engine is not able to provide that required torque at a particular speed; it has different Torque/Speed Characteristics. The need is therefore to match the Torque/Speed Characteristics of the vehicle and the engine.
Where the power required is comparatively not so high, matching of Torque/Speed Characteristics of the vehicle and the engine is done through a Gearbox, as in the case of Trucks, Buses, Cars, and Two- and Three-Wheelers, and in fact, any internal combustion driven vehicle driven between these sizes.
For a large Diesel Locomotive, the power involved near about 4,500 HP makes a Gearbox impractical. So these big machines are driven by electric motors both, AC and DC, driving each wheel. The engine drives an Alternator. The Torque/Speed Characteristics are matched by solid state power electronics. The right amount of voltage and current is delivered to the wheels, matching the load on the train and the speed set by the locomotive engineer.
The weight penalty incurred by the additional equipment is essentially insignificant compared to the weight of the train. Moreover, the efficiency of electric generators and motors can be quite high.
Another reason is getting the train to initially move. If using a diesel engine only, then a Gearbox would be required. The diesel engine develops very little torque at low RPM. But, given that a freight train weighs as much as 8k – 10k tons, the Gearbox would likely be destroyed. Additionally, a diesel engine produces very little torque at standstill condition. So the problem becomes how to start the train moving, with very little torque available, and virtually assured destruction of the Gearbox.
The solution is an electric motor. An electric motor produces its max torque at zero RPM i.e. at standstill condition. A large electric motor can produce sufficient torque to start the train moving. After initial movement is initiated, torque requirements begin to drop.