Does the same applies to old iPhones? Can the iPhone 5 run the most recent version of let's say the Facebook/Messenger app?
Yes. The iPhone 5 has received iOS 10, so it can run all iOS 10 apps in their most recent versions. There are some (mostly hardware) features that iPhone 5 users don't have access to (e.g. 3D Touch) so they might not be able to use all power features, but that doesn't prevent you from using the complete fully updated app catalog.
As an iPhone 5S user, I don't feel like I'm disadvantaged at all from having a phone that is three generations behind.
The situation is pretty complex but the support libs & play services are available on virtually all devices (API 9+ IIRC, but anything older would not be able to run most modern apps).