The story
Compound of ton + mile, although, as with any such unit of measure (e.g., person-months, newton metres), the mathematical relationship of multiplication is simultaneously involved: X tons transported a distance of Y miles = X × Y = Z ton-miles. Attested since the 19th century in railway logistical usage; greatly increased in use by the logistics boom of World War II and the continued postwar development of advanced logistics.
Etymology from Wiktionary, CC BY-SA 4.0.