What does the pole in not touch something with a ten-foot pole refer to?
Before the 20th century, the pole was a common measuring device and evidence suggests that the figure ten-foot was a conveniently rounded number; the expression is, essentially, a hyperbolic statement, and was probably the inspiration for the more recent British idiom wouldn't touch sth with a barge pole (1877). It's worth noting that earlier versions had the form with the end of a barge pole, as seen below.
Mostly Fools: A Romance of Civilization (1886)
As for me I wouldn't touch one of 'em, much less yours—not if he were the Pope of Rome—not with the end of a barge pole—not if I were paid for it, there now; and I wish I'd never been born to be slave to such a brute beast, I do—booooh! ”
How old is the ten-foot rod / perch / pole?
Talking of Popes, the precise origin of the ten-foot pole can be traced back to Ancient Rome.
As far back as the first-century BC, Roman surveyors and engineers used a rod called a decempeda, which measured ten Roman feet: (decem) ‘ten’ (pedes) ‘feet’. The term decempeda was also known as pertica from which the English word, perch, is derived.
decempeda
It was usually of square section capped at both ends by a metal shoe, and painted in alternating colours. Together with the groma and Dioptra the decempeda formed the basic kit for the Roman surveyors. The measuring rod is frequently found depicted in Roman art showing the surveyors at work. Wikipedia
The rod became an essential unit of measurement in England. Ever since 1324, an acre of land had been defined as the “area of four perches in width by forty perches in length.” However, a rod (perch, pole) was not ten but fifteen feet long. Even more confusingly, the rod as a survey measure was standardized by Edmund Gunter in England in 1607 as one-fourth of a chain (of 66 feet (20.12 m)), or 16 1⁄2 feet (5.03 m) long.
Despite the issues of royal ordinances over the centuries, weights and measures continued to be arbitrary. Finally, in the early 17th century, a list of units and standards was agreed upon and fixed. The result of which led to the calculation of the perfect acre of land as being an area of 40 rods (in length) and 4 rods (in breadth), i.e. 160 square rods.
This explains why we come across written instances of 10-foot rod, and even 40-foot pole

Although the House of Representative's report was printed in 1858, the “homely” expression is said to be uttered by the Federal Judge, John Charles Watrous, in 1851. Another witness later recalls:
Judge Watrous turned round and said, I would not touch them, sir, with a forty-foot pole. The reason why I remember these words is, that I thought they were undignified for a judge to use.
The English system of measurement had been adopted by the United States and it continued to be in use in spite of the British 1824 Weights and Measures Act that introduced the Imperial system of units and repealed the medieval Composition of Yards and Perches (Compositio Ulnarum et Perticarum), dated from 1250 to 1305.
In Triumph of Criticism. A critical and paradox work on the Bible, published in 1869 (Philadelphia), we see another variant of the American idiom:
But on meeting with universal discouragement from book publishers to whom I applied, in regard to the practicability of such an undertaking – one even refusing to touch it at his risk with a ten foot rod!– the project was for some time held under consideration
Thus the ten-foot rod (or perch) was originally a Roman measuring tool called decempea or pertica, whereas the rod was an old Saxon unit probably equal to 20 “natural feet” (pes naturalis, about 9.8 inches), which measured approximately 16.333 feet.
Examples of “ten-foot rod” in 17th century
A Large Dictionary In Three Parts: (1677)
Decempeda, Cic. instrumentum seil. [?] pedum decem. perch, or rod of ten foot long
Philosophical Transactions (May 20. 1684)
…to be exprest on a marble Table in the Capitol, together with the Roman Palm of nine inches, and the Canna Architectonica of ten Palms, and the Decemeda or Rod of ten Foot.
Mechanick exercises: or, The doctrine of Handy-Works (1693)

We shall begin therefore to measure the Ground-plot, to which Carpenters use a Ten-Foot Rod for expedition, which is a Rod about an Inch square, and ten foot long; being divided into ten equal parts, each part containing one foot,…
Mellificium Mensionis: Or, The Marrow of Measuring (1727)

…to wit, Length, Breadth, and Thickness, to be multiplied each by the other; and this kind of solid Mensuration serveth for the measuring of Timber, Stone, Digging, Bricklayers Work, for it is commonly reduced to a Thickness, and all manner of solid Bodies whatsoever.
The Instruments that are used in taking of the Lengths and Heights (or Breadths) in measuring of the following Works, are a ten Foot Rod and a five Foot Rod, and a two Foot Ruler, and sometimes a Line.
Earliest examples of “ten-foot pole”
Chronicling America, the free online resource that has copies of American newspapers from 1789 to 1963, did not produce any results for "ten foot pole", "ten foot rod", or even "ten-foot" between 1789 and 1830. On the other hand, I did find an 1852 article which cites the forty-foot version of the ever popular idiom.
…and declared himself a regular built “fire-eater”–his steam was up–no man living north of Mason and Dixon's line would he “touch with a forty foot pole,” and as for a Yankee–the idea was spasmodic. His “voice was for war” and resistance.
Flag of the Union., August 13, 1852
and in the Wilmington Journal., September 23, 1853
Why is it, or how is it that the currency of the District of Columbia is so much worse than that of any State or territory in the Union. […] Furthermore, at New York, Philadelphia […] etc., take our North Carolina money freely: while at the office of the South Carolina Railroad in Charleston, […] they look at it as though it were an unclean thing–not to be touched with a forty foot pole. Why can this be?
However, thanks to Google Books, I unearthed one instance of ten-foot pole between 1700 and 1800, dated 1729 it is almost ten years earlier than the 1738 citation in @KarlG's answer.
An Introduction to a General System of Hydrostaticks and Hydraulicks (1729)
To effect the same by the Water or Spirit-Level, you are to stand at the Spring-head, and having turn'd your Instrument on the hanging Level, or, in other plainer Words, on the Hang of the Hill where the Water is to pass, let your Assistant set forwards with a ten Foot Pole or Rod in his Hand and holding his Hand at about four or five Foot high, and let him move up and down the Hill till the Level exactly strikes the Assistant's Hand;
19th Century: The New York Daily Times
The idiomatic expression made its first appearance in the NYDT on September 28, 1898.
District Attorney Asa Bird Gardiner, who was here long before the Tammany delegation arrived, was asked this afternoon if there was any truth in certain reports that he might be a candidate for the Gubernatorial nomination.
“I wouldn't touch the nomination with a ten-foot pole” said the Colonel. “I talked with Mr. Croker about it, and that's what I told him. There is really no reason why I should want it.”
Why didn't the 10-foot pole expression take on until the 1850s?
The answer probably lies in the blacksmith trade and St Dunstan, Archbishop of Canterbury in 960. He was, reputedly, a skilled blacksmith and jeweller and is generally venerated as a patron saint of smiths.
A traditional English rhyme recounts a late 11th-century legend when St. Dunstan is said to have rejected the devil's temptation by using a pair of red-hot tongs.
St Dunstan, as the story goes,
Once pull’d the devil by the nose
With red-hot tongs, which made him roar,
That he was heard three miles or more.
Wikipedia
It is likely, but I've not found any references that confirm my suspicion, that this folk story bore the 17th-century expression not touch one with a pair of tongs
I will not touch them with a paire of Tongues 1646 Winslow Hypocrisie
The expression remained popular until the late 19th century
“For without a payre of tongs no man will touch her”. 1640, Wit Restor'd, and Wits Recreations
“Those who have more liberal notions, and a more extensive knowledge of the human heart, can readily comprehend how a lady may think a man so odious at one minute that she could not touch him with a pair of tongs, and so charming the next that she would die a thousand deaths for him, and him alone.” 1811, Popular Tales, Volume 1
“I was so ragged and dirty that you wouldn't have touched me with a pair of tongs.” 1854 Dickens, Hard Times
“Aw wouldno' touch him wi' a pair of tungs, sir!” 1901 Lancashire sayings