'My thing' as my métier, in 1841 and after
The 1841 reference to "do your thing" that Josh61 cites appears to be a reference to Ralph Waldo Emerson's essay "Self-Reliance," first published in 1841. Here is the relevant piece of that essay:
What I must do is all that concerns me, not what the people think. This rule, equally arduous in actual and intellectual life, may serve for he whole distinction between greatness and meanness. It is the harder, because you will always find those who think they know what is your duty better than you know it. It is easy in the world to live after the world's opinion; it is easy in solitude to live after our own; but the great man is he who in the midst of the crowd keeps with perfect sweetness the independence of solitude.
The objection to conforming to usages that have become dead to you, is, that it scatters your force. It loses your time and blurs the impression of your character. If you maintain a dead church, contribute to a dead Bible-society, vote with a great party either for the Government or against or against it, spread your table like base housekeepers,—under all these screens, I have difficulty to detect the precise man you are. And of course, so much force is withdrawn from your proper life. But do your thing, and I shall know you. Do your work, and you shall reinforce yourself. A man must consider what a blind-man's-buff is this game of conformity.
Why Ralph, you old hippie, you! Down with conformity; do your thing; tune in, turn on, drop out! I don't know whether Emerson's comment had any influence on the emergence of the phrase "do your thing" in the 1960s and 1970s, but a lot of young people read Emerson then (for school), and I was very pleasantly surprised to see how prescient his 1841 use of "do your thing" was.
To demonstrate that Emerson was not the only pre-1960s person to use "[one's] thing" in the sense of one's interest or area of activity, I offer this example from Daphne Du Maurier, I'll Never Be Young Again (1932) [combined snippets]:
Perhaps she had been frightened at living alone in the rooms by herself. I had sent her a letter the first day of my arrival in London, and nothing after that. She must have known that letters were not my thing, she surely had not expected to hear from me every day. She knew I would come back. That was all that mattered.
'Your thing' as a proclivity or special interest, in the 1960s and 1970s music lyrics
There are actually two strains of meaning to "my thing"/"your thing" as used in the 1960s and 1970s. One is the laid-back, "following my own path" sense of the phrase, which finds expression in the Bob Dylan song "If Dogs Run Free," from his album New Morning (1970). Sample lyrics:
If dogs run free, then why not we/Across the swooping plain?/My ears hear a symphony/Of two mules, trains and rain./The best is always yet to come,/That's what they explain to me./Just do your thing, you'll be king,/If dogs run free.
Isaac Hayes's "Do Your Thing" (1971) takes a a broad view of what your thing might be:
If the music make you move,/'cause you can really groove/Then groove on, groove on/
If you feel like you wanna make love/Under the stars above/Love on, love on/If there's something you wanna say,/And talkin' is the only way/Rap on, oh, rap on/'Cause whatever you do,/Oh, you've got to do your thing
A 'thing' as an intimate relationship in 1960s and 1970s lyrics
In one sense, a thing could refer simply to an intimate relationship, as in Simon & Garfunkel's "We've Got a Groovy Thing Goin'" (from the duo's 1966 album Sounds of Silence):
We got a groovy thing goin' baby, got a groovy thing.
Billy Paul's "Me and Mrs. Jones" (1972) is somewhat more forthright about the relationship there:
Me and Mrs Jones, we got a thing going on/We both know that it's wrong/But it's much too strong to let it go now
'My thing' as a source of sexual desire or jealousy in 1960s and 1970s lyrics
Somewhat suggestive of the same notion is the Isley Brothers' 1969 song "It's Your Thing," but here the thing isn't necessarily just a proclivity or a relationship but (suggestively) also corporeal:
It's your thing/Do what you wanna do/I can't tell you/Who to sock it to.
That same year, Marva Whitney released a response song titled "It's My Thing (You Can't Tell Me Who to Sock It To), which puts considerable emphasize on the notion that possessing one's own thing leads as a matter of natural right to freedom of choice in the choice of a sockee.
In 1973 Sylvia Robinson included a song titled "My Thing" on her Pillow Talk album, where the phrase seems to refer either to her special relationship or to the person himself:
I told you girl, he's my special prize./When I turn my back,/You want to try him on for size./I don't want nobody in the world,/Messin' around with my thing,/My sweet, tender, lovin', groovy thing./(She don't want nobody in the world,/Messin' around with her thing.)/Hands off, you hear me./Leave my thing alone.
And in 1974, James Brown released "My Thang," which offers the following lyrical advice:
If you wanna get down with a broad/This is the way you do it/Walk up and rap to her/Put your hand on her lower left arm/You know/And this is what you rap to her/I mean, come on like you should/Come on with your come on/Gimme, gimme your thing/Gimme, gimme my thing/Gimme, gimme my thing/Feels so good, let's get it on/Gimme
'My thing' as a source of sexual desire in 18th-century lyrics
Somewhat surprisingly, this last sense of "my thing" goes back to the English folk song tradition as the lyrics to "My Thing Is My Own" indicate. This is how the song begins:
I a tender young Maid have been courted by many,/Of all sorts and Trades as ever was any:/A spruce Haberdasher first spake me fair,/But I would have nothing to do with Small ware./My Thing is my Own, and I'll keep it so still,/Yet other young Lasses may do what they will.
This song appears in Henry Playford, Wit and Mirth: Or, Pills to Purge Melancholy; Being a Collection of the Best Merry Ballads and Songs Old and New, volume 4 (1719), and may it may be considerably older than that.
These examples—especially Emerson's from 1841 and Playford's from 1719—indicate that "my thing"/"your thing" has been around for centuries, with various colloquial meanings attached to it. The word thing invites both generalized and euphemistic usage, so it really isn't surprising that people have been taking advantage of those flexible features for a long time.