The (meager) evidence
The story gets partially revealed through Mrs Lovett's song "Poor Thing".
There was a barber and his wife
And he was beautiful
A proper artist with a knife
But they transported him for life
And he was beautiful
(Mrs Lovett) Barker his name was, Benjamin Barker
(Sweeney) Transported? What was his crime?
(Mrs Lovett) Foolishness
And the quote you linked states that he was found on the ocean:
"If you hadn't found me, I'd be lost in the ocean still"
Puzzling the pieces together
- Benjamin Barker was sentenced as a criminal on bogus charges, by a corrupt judge and beadle.
- As was customary for the time, criminals would be transported to criminal colonies. This is evidenced by Sweeney's assumption (when he says "Transported? What was his crime?") Most famously, Australia was such a British penal colony, but there are other possibilities too (e.g. the Caribbean). As far as I'm aware, it's never truly specified; though others have claimed in this answer that it was Australia.
- Being found at sea implies that Benjamin escaped from the penal colony, hoping to make his way back home. This is where Anthony's ship picked him up and rescued him.
Personally, I think this suggests that Benjamin was trapped on a small island. If he were trapped on an island the size of Australia, he'd be more likely to flee away from the prison and find a proper boat to head home on.
Being lost at sea (literally; though Sweeney is indeed implying he was also figuratively lost), in my opinion, suggests that the entire island must have been the prison; which is simply not possible for Australia due to its size.
I dug a little deeper, hoping to find a small island that was used as a penal colony. From the Wikipedia page on penal colonies:
When that avenue closed in the 1780s after the American Revolution, Britain began using parts of what is now known as Australia as penal settlements. Australian penal colonies included Norfolk Island, Van Diemen's Land (Tasmania), Queensland and New South Wales.
From the Wikipedia page about Norfolk Island:
34.6 km2 (13.4 sq mi)
The island is small enough that Benjamin Barker would be unable to flee the prison without fleeing the island; thus suggesting that he'd need to escape by raft.
Note: He could hide out on the island, possibly, but he'd likely have to end up building a raft anyway. The odds of the prison not being in control of the island's harbor are slim to none.
The island served as a convict penal settlement from 6 March 1788 until 5 May 1855
According to IMDB, even though the chronology was intentionally kept vague (IIRC the Tower Bridge, which we see in the intro, wasn't yet built in the 1800s):
The play itself was set around 1846.
Which would make Norfolk Island a viable candidate, both in size and timing of being a penal colony.
Second (and last) update!
I looked up the quote you referenced in the official script, and it reveals slightly more:
I owe you my life, Anthony. If you hadn't spotted me, I would be lost on the ocean still ... Thank you.
This highly suggests that spotting him saved his life. This heavily suggests that he was on a raft, and would have died if no one had found him.