The cheapest I've found is in northern Russia, from Воркута́/Вӧркута/Vorkuta (Komi Republic) – Коноша/Konosha (Arkhangelsk Oblast) , I find a ticket for a seat for 1399 RUB for 1559 km. That is €17.563, or 0.01127 €/km or 1.127 €¢/km.

Further west,
Göteborg – Narvik, booked early in the low season, I find tickets in a seat for SEK 562 (€60.13). The train travels via Stockholm, which gives a distance along the road is around 1900 km, along the railway should be similar. This gives a price of 0.03164 €/km or 3.164 €¢/km.
Tickets are flexibly priced, so you might find cheaper tickets for specific routes and dates. Students and youths get a discount. Refundable tickets cost more (803 SEK / €86 for a seat or 898 SEK / €97 for the low-season connection I was looking at, mid-week in May which is 2–3 months away, but it depends on date and time).
(I do not recommend taking just a seat. For SEK 609 (€65), or just 47 SEK (€5) extra, you will get a couchette. It again depends on the time/date of booking.)
Stavanger – Bodø, I find minipris for 449 NOK, or €47.58, a seat for a journey taking more than 24 hours. Distance along a route similar to the train is some 1754 km, which brings the price of 0.02723 €/km or 2.723 €¢/km.
The most expensive may be the Gornergratbahn, which costs CHF 43.00 (€39.73) for 9.3 km, or around €4.27/km. Not even British Anytime tickets reach that price level. But that's not a long distance rail route. For the most expensive long distance rail route, you should probably be in the United Kingdom.