I’ve been asked this a few times by writers and editors alike, so I’ll see if I can answer it here. Keep in mind, this is my opinion. While it’s grounded in my research, it’s still mine. Yours might differ. That guy over there might have another idea entirely. This is how I handle the situation.
First, I consider the semantics of the sentence this appears in. Let’s take this one: “Hang on to/onto that ledge!” I’m shouting at someone to grip the ledge (of a building, or a rock face, or whatever). That’s the meaning, the semantics: “Grip that ledge!”
So, “hang on to/onto” has to mean “grip” in this particular example.
“Hang on” is a multi-word verb. There’s a verb form (“hang”) and an adverb particle (“on”). [I bet you thought “on” was a preposition. Heh. That’s what I was taught back when rocks were new, too.] It can mean “grip” or “hold” or “take” or “stop/wait.” “Hang on a minute!” I’m not telling anyone to touch anything; I’m telling them to wait or stop what they’re doing. I could also say simply “Hang on!” I’d also use this version (just the verb, nothing else) if I’m telling someone to grab/grip/grasp whatever’s in reach because, presumably, if they don’t, they’ll be injured somehow (perhaps flung from a speeding Ducati). Here’s a link to a great article about multi-word verbs over at the Cambridge Dictionary site. You’ll see “hang on” listed as a phrasal verb. (The other types are prepositional verbs, like “break into,” and phrasal-prepositional verbs, like “get on with.”)
This is why, when I’m editing text and I see “hang onto,” I nearly always change it to “hang on to.” I honor the structure of the phrasal verb “hang on” and separate the preposition “to” in order to let it attach, syntactically, to the object that follows: “Hang on to that ledge!” (As you saw in the previous paragraph, “hang on” does not necessarily pair with an object.)
That’s my reasoning and my answer. Do with it as you see fit.