Your average truck puts out 8 metric tons per axle [1], railroads have to deal with 20-25 tons per axle [2] (and records of 40 tons/axle in Australia [3]). That is an awful lot more force that needs to be distributed into the ground, particularly as trucks usually reach only 80 km/h whereas freight trains run at 120 km/h in Europe [4].
Additionally, road vehicles have way more tolerance for shoddy road conditions - small bumps and potholes won't bother them too much, even at higher speeds, whereas rail vehicles are really, really prone to (deadly) derailments when the track goes bad for whatever reasons.
All of that makes constructing rail way more complex and as a result expensive.
[1] https://en.wikipedia.org/wiki/Road#Maintenance
[2] https://www.forschungsinformationssystem.de/servlet/is/32505...
[3] https://en.wikipedia.org/wiki/Axle_load
[4] https://de.wikipedia.org/wiki/G%C3%BCterzug#Geschwindigkeite...
And the only way to achieve that capability is lots and lots of very thick steel.
> It's too bad rail is so expensive to make compared to roads.
Is that actually true? I mean, by what measure is rail more expensive? In comparison to rail road travel is massively subsidised. If we break down cost it would be interesting to see how they actually stack up against each other.