I know that "Stick to your knitting" means to stick with what you're familiar with/good at rather than giving your opinion or trying your hand at something out of your area of expertise. But I can't find anything about where this comes from. I've seen some theories about chauvinistic dismissal or women knitting during executions during French Revolution, but the sources sounded highly speculative.
A Google Books search finds several instances of "stick to [one's] knitting" from the late 1800s, including this one in The Pharmaceutical Era (April 28, 1898) that suggests the term was already an established saying in U.S. English:
"STICK TO YOUR KNITTING."
There is naturally a temptation with every advertiser to work into his advertising some of those things which are uppermost in his mind at the time of writing, or make allusions to topics which are prominently in the public mind. Thus we have had Klondike advertising—show windows with the paraphernalia of mining and references to Alaskan gold miners in newspaper advertising. There is now a tendency to use the Spanish-American difficulty as an advertising text, and make newspaper space and show windows play a weak and second fiddle to news reports and the rumors which are back of general conversation.
In the heat of anticipated events there will be hard work to keep "war" out of advertising. It goes against the grain to keep still when everybody seems to be talking upon a subject in which you are interested. It seems almost like a repression of patriotism. But, as much as we admire the drum major, we should remember that there is the quartermaster somewhere in the rear, who in the din and glory of battle, must remain unrattled and calmly figure out problems of bean rations and army mules. He must attend strictly to business, and the advertiser must do the same. There is a homely old injunction which originated in our homespun days which the advertiser might recall. It is this: "Stick to your knitting."
The earliest Google Books match is from A.I. Root, "Myself and My Neighbors," in Gleanings in Bee Culture (December 1, 1890):
Yes, I say to my shame, that my truant mind sometimes gets away on Sundays, even during sermons, and plans this new greenhouse, instead of listening to our good pastor. And now during this fine weather in November I have been trying to get time to instruct workmen how to build it after the plans have been so long working and evolving in my busy brain. As a consequence, things have been somewhat neglected. Some days I feel as if I had no business in thinking about greenhouses at all—that I had better let well enough alone, and "stick to my knitting" —the journal, factory, etc.
Only slightly younger, from Rollo Ogden, "A Spanish Bluestocking," in The Christian Union (March 12, 1892):
Adding high quality, too, as we must, to this extraordinary quantity [of literary output by Emilia Pardo Bazán], taking account of the learning and wit and vivacity to be found in these twenty-seven volumes, we are forced to fall in with the opinion of that ungallant critic, Leopoldo Alas, who says that all but two of the large number of Spanish female writers would do better to stick to their knitting, but who is driven to confess that Señora Bazán would be a notability in any literature, while in that of Spain she is a veritable prodigy.
And from Richard Woods, "Decadence of Carrier and Barb Pigeons," in Michigan Poultry Breeder (1894):
It must be evident to everyone who takes any interest at all in pigeon culture that during the last few years, those old established varieties, the Carrier and the Barb, have lapsed into comparative obscurity, and it is equally well known that this radical change has not taken place suddenly. Indeed, it has been patent to me, for ten or a dozen years or more, that as time went on, and fanciers became better versed in the points and properties of the different breeds of fancy pigeons, a great change of fashion or affection‚ whichever we choose to call it—would take place. I do not wish to pose a prophet," nevertheless I feel it incumbent upon me to caution present day enthusiasts of one or two other varieties against a similar danger that is now staring them in the face. What that danger is I will presently explain. — Meantime, I must stick to my knitting, "The decadence of Carriers and Barbs."
Three of the first four instances of the phrase in the Google Books results are thus delivered in the context of specialized work and are refreshingly gender-neutral. Many of the subsequent results from the first two decades of the twentieth century follow this same pattern, with examples from American Thresherman, Electrical Merchandising, The Tobacco Worker, The Bricklayer, Mason & Plasterer, Telephony, American Printer & Lithographer, The Pottery & Glass Salesman, among many others.
A not uncommon example comes from Proceedings of the National Safety Council (1918):
You cannot see it in an individual meeting, but you will see it when you sum up. My advice to all men is to stick to your knitting and take care of your committees.
It is also notable that for the period 1900–1923 a Google Books search finds 29 unique matches for "stick to his knitting," whereas for the period 1900–1939 it finds only four instances of "stick to her knitting"—on of them involving a chicken, and another to Mother Nature.
Still, the kernel of implied gender bias may be found in the recommendation by the "ungallant critic Leopoldo Alas" that most Spanish female authors should "stick to their knitting"; and it wouldn't surprise me if, as the decades went by, "stick to your knitting" became more and more understood as a piece of advice directed toward women (and not toward men).
Also, an earlier form of the expression goes back considerably farther, with an unmistakable gender-conscious edge. From John Austin, "A Voice to the Married," in Evangelical Magazine and Gospel Advocate (June 28, 1839):
In neglecting to repose this confidence in his wife, does not the husband cast an ungenerous suspicion upon her capabilities? When he keeps her in as total an ignorance of his affairs as possible—when he will not deign to consult her even in relation to transactions of the most grave and weighty importance, and which may involve her and her children in poverty and want through life—what is it but virtually saying to her—"your mind is too feeble, your discernment too contracted, your general ignorance vastly too great to become my adviser!—attend to your knitting and sewing, look after the cooking, take care of the children—for these are all the subjects which you have ability to comprehend!"
A final word on that older form of the expression comes from Joe Chapple, "Excuses," in The Reminder (December 1916):
There used to be an old saying in this country that had more meat in it than almost any business maxim of the present day and that was 'Attend to your knitting.' Men don't knit, I know, but their grandmothers did, and one loose thread or one careless tangle would 'ruin the whole shawl.' If I were in a Business Congress right now I would move for unanimous consent to a revival of the old advice, 'Attend to your knitting,' and then if anything happened every man would know that it was his fault.
This quotation strongly suggests that the point of the saying "Attend to your knitting" was that a person should pay full attention to the task at hand, in order to do good work. The shift to "stick to your knitting" altered the point of the saying to mean something like "do the thing that you are good at doing," which is a very different piece of advice.
I found the following passage in The American Bee Journal, dated June 13 1883, on the subject of Italian and Hybrid Bees:
But two years ago this spring I found out the difference between brown and black bees. We all have in mind that sever winter and spring. I lost over 60 colonies, and to help fill up my empty combs, soon enough to be able to obtain some surplus, I bought 20 colonies (19 of them blacks), and they were black too, black as an old boot, and as cross as a setting hen. I left them at a neighbor's, 1½ miles away from home, so as not to mix with my Italians. I then Italianized what I did not trade off. Years previously I had tried different strains of Italians, mostly light ones, but they would swarm when I tried to crowd them into the honey boxes, while my old brown bees would fill a set of boxes, then notify me they wanted more room, and take what I gave them in a contented sort of a way, and "stick to their knitting."
This seems to give a sense of minding your own business, or being content with your lot. From the context, it's not entirely possible to glean precisely what the author means by the phrase.
However, nearly 50 years earlier in 1835, in Horse Shoe Robinson; a Tale of the Tory Ascendency, the author (John Pendleton Kennedy) uses the phrase Go to your knitting to mean stick to those things that you understand:
'You are entirely out of my depth, brother,' interrupted Mildred.
'I know I am. How should women be expected to understand these matters? Go to your knitting, sister: you can't teach me.'
A little further back, in 1828, the phrase Mind your own knitting is defined as Mind your own business in An English and Welsh Dictionary, Volume II. The format is rather difficult to reproduce here, so I've added the image below.
Incidentally, the Welsh translation means something along the lines of Look after your own task yourself, which ties in nicely with the later meaning of the phrase stick to your knitting
This page cites several usages from the early 1900's.
The usages cited there, such as "No, you'd better mind your own business, girl. Forget your foolishness and ‛tend to your knitting.", do appear to have a chauvinistic quality.