It isn't certain how '23-skidoo' (or skiddoo) originated. There are numerous competing theories; which is a sure sign of doubt. It seems that '23' originated as a fad term in the USA in the early 20th century.
In 1899, George Ade explained the slang term "twenty-three". This story appeared in an October 1899 edition of The Washington Post:
"By the way, I have come upon a new piece of slang within the past two months and it has puzzled me. I just heard it from a big newsboy who had a 'stand' on a corner. A small boy with several papers under his arm had edged up until he was trespassing on the territory of the other. When the big boy saw the small one he went at him in a threatening manner and said: 'Here! Here! Twenty-three! Twenty-three!'. The small boy scowled and talked under his breath, but he moved away. A few days after that I saw a street beggar approach a well-dressed man, who might have been a bookmaker or horseman, and try for the unusual 'touch'. The man looked at the beggar in cold disgust and said: 'Aw, twenty-three!'. I could see that the beggar didn’t understand it any better than I did. I happened to meet a man who tries to 'keep up' on slang and I asked the meaning of 'Twenty-three!'. He said it was a signal to clear out, run, get away. In his opinion it came from the English race tracks, twenty-three being the limit on the number of horses allowed to start in one race. I don’t know that twenty-three is the limit. But his theory was that 'twenty-three' means that there was no longer any reason for waiting at the post. It was a signal to run, a synonym for the Bowery boy’s 'On your way!'. Another student of slang said the expression originated in New Orleans at the time an attempt was made to rescue a Mexican embezzler who had been arrested there and was to be taken back to his own country. Several of his friends planned to close in upon the police officer prisoner as they were passing in front of a business block which had a wide corridor running through to another block. They were to separate the officer from the prisoner and then, when one of them shouted 'Twenty-three,' the crowd was to scatter in all directions, and the prisoner was to run back through the corridor, on the chance that the officer would be too confused to follow the right man. The plan was tried and it failed, but 'twenty-three' came into local use as meaning 'Get away, quick!' and in time it spread to other cities. I don’t vouch for either of these explanations. But I do know that 'twenty-three' is now a part of the slangy boy’s vocabulary."
'Skiddoo' is another slang term, also originating around the same time and place, meaning much the same as 'skedaddle', i.e. 'leave', 'depart', 'get out of here'.
Here are a few theories as to how '23' and 'skidoo originated' - there are others:
1. In Charles Dickens’ Tale of Two Cities, Sidney Carton is No. 23 of a multitude executed by the guillotine. "In the last act of the theatrical adaptation, 'The Only Way,' an old woman sits at the foot of the guillotine, calmly counting heads as they are lopped off. The only recognition or dignity afforded Carton as he meets his fate is the old woman emotionlessly saying 'twenty-three' as he is beheaded. 'Twenty-three' quickly became a popular catchphrase among the theater community in the early twentieth century, often used to mean, 'It’s time to leave while the getting is good."- Who Put the Butter in Butterfly? by David Feldman, Harper & Row.
2. " …in the first few years of the century, memorabilia sold at vacation resorts and fairs were emblazoned with either 23 or Skidoo, and the two soon met." (Dalzell quoting Partridge.)
3. "Tom Lewis originated the fad word '23' in 'Little Johnny Jones' in 1904, and 'Skidoo' was tacked on later. (Dalzell quoting Partridge.)
4. "23 was possibly derived from a telegraphic shorthand code, not unlike trucker CB code, meaning Away with you!'" (Dalzell quoting Partridge.)
5. Thomas Aloysius Dorgan (TAD), a cartoonist and sportswriter, coined the phrase. The expression never appeared in his work but the simple 23 did appear in a comic published on February 16, 1902. (Dalzell.) Skidoo was simply a fanciful variant of skedaddle." (Feldman)
Skedaddle, according to "The Dictionary of Contemporary Slang" by Tony Thorne, Pantheon Books, originated in the American Civil War and "…suggestions have been made as to the word’s derivation; it is probably a form of a dialect version of scatter or scuttle."
6. 23-skidoo came from an expression that construction workers used while building the Flatiron Building on 23rd Street in N.Y.C. 23rd Street is one of the wider streets in New York that is like an uninterrupted wind-tunnel between the East and Hudson Rivers. Frequently, when one is walking north or south on the avenues and comes to such an intersection, they can experience a sudden blast of wind as soon as the pass the wall of a corner building. Apparently, when the workers sat on the sidewalk to eat their lunches, they would watch women's skirts blow up from the sudden gusts.
7. The phrase originated in the Panimint Mountains in Death Valley in the early 1900s. The mining town of Skidoo had 23 saloons and if you were going to go get drunk you would try to get a drink at each of the saloons. This started the phrase of going 23 skidoo if you were going to have a good time.
Whatever the source, the term was much in vogue in the USA during 1906. In that year there are many examples of its use in various contexts in US newspapers, and no such entries date from 1905 or before.