That homeless battery cable in the engine compartment was probably attached to a battery isolator, that probably failed and was never replaced. Many older motorhomes put them in the engine compartment area for ease of access to the chassis battery for connectivity. There would usually be 3 connections on it, one for the alternator feed in and 2 out to the chassis/coach batteries. The chassis circuit was often run through a diode, to prevent reverse current traffic from the chassis battery, while drawing from the coach batteries, as others have suggested.
Mike. Comments are anecdotal or personal opinions, and worth what you paid for them.
2018 (2017 Sprinter Cab Chassis) Navion24V + 2016 Wrangler JKU (sold @ ????)
2016 Sunstar 26HE, V10, 3V, 6 Speed (sold @ 4600 miles)
2002 Roadtrek C190P (sold @ 315,000kms)