To a T (also, 'To a Tee') is a common English idiom meaning 'exactly' or 'perfectly'. Common examples of modern use include 'down to a T', 'suits to a T', and 'fits to a T'.
The phrase first appeared in writing in 1693, but it was almost certainly a shortening of an earlier phrase -- however, there is some debate as to what that phrase might have been.
The most popular theory is that is is a shortening of the phrase "to a tittle", first seen in writing in Francis Beaumont and John Fletcher's 1607 play, The Woman Hater. A 'tittle', in this case, is the technical term for the dot over the lowercase i or j. This origin is supported by the fact that 'jot and tittle' was a common phrase at the time, appearing in English translations of the Bible (specifically, Matthew 5:18) since 1526; in this case 'jot' is the name of the smallest letter of the Greek alphabet, iota, which has long been used to refer idiomatically to a small thing or amount.
An alternate theory, somewhat less likely, is that the T referred to is tau, the last letter of the Phoenician alphabet and/or taw, the last letter of the Hebrew alphabet. In early medieval times the expression 'alpha and omega' was sometimes alternately given as 'alpha and tau'. However, the dates in this case do not work out very well, so the former theory is much more likely.