Trying to make a summary to answer the original OP's question, I would say the following rail services exist mainly or significantly for the ferries:
- Morecambe - Heysham Port. ~7000 passengers per year, only a couple of trains per day, only 2 ferry crossings per day, with limited passenger capacity, and foot passengers generally directed via Liverpool.
- Ardrossan branch: ~130,000 passengers per year to the harbour station, compared to only ~20,000 to Ardrossan Town, so around 85% ferry passengers. A total of around 850,000 passengers use the ferry, so around 15% of them arrive by train.
- Fishguard branch: ~14000 passengers per year to Fishguard Port, and ~20000 other passengers from Fishguard & Goodwick, so around 40% ferry passengers.
- Lymington branch: ~140,000 passengers per year to pier station, and 270,000 to town, so around 33% ferry passengers. The train is half hourly, and the ferry has been reduced to hourly.
- Weymss Bay Line: ~210,000 passengers from Weymss Bay, probably most of them for the ferry, which carries around 700,000 per year. Around 300,000 from the other stations on the line, so probably 30% for the ferry.
- Mallaig branch: The ferries from Mallaig carry around 300,000 passengers per year total (including vehicle and other non-train passengers). ~98,000 rail passengers into the station per year, difficult to estimate %'
- Harwich branch: ~110,000 passengers per year to the International station, most of whom are presumably for the ferry, around 400,000 to the other stations on the branch, so around 25% for the ferry
For other lines such as Gourock, Portsmouth Harbour, Holyhead and Oban, even the terminus station probably has less than 50% ferry traffic - taking Gourock as an example, 500,000 passengers use the station per year, but there are only 300,000 on the Calmac ferry, some of which won't be taking the train.
I would say that Heysham and Fishguard probably fall under the 'scarecly worth running' category, with all of the others very much worth running.