Railways have the highest fixed costs of any transportation system. 25%, I was told 30 years ago when I worked on one.
High fixed, low variable cost. So adding one freight car = dirt cheap. Going one mph faster on a curve = very expensive, due to increased wear on rails, road bed, etc.
There is also the not small problem of grade. Trains dislike hills, with a grade over 1% being excessive to them. Cars routinely handle ten times this.
Grades dictate routes. The only way around this is tunnels & bridges. Either way, cost per mile for a track is much higher than for a road. With costs born by one company, rather than all of us.
It is a fundamental problem, that leads to the division of bulk (slow) hauling = railways, people & fast hauling = trucks/cars.