Dude has its origins in what Shakespeare would call a "clothes wearing man".
The article "Words and Their History", by R.W. McAlpine, printed in Dodge's 1901 St. Nicholas, Volume 28, Part 2, cites an even earlier appearance in print: 1876, with common usage beginning as early as 1873.
It goes further to suggest that dude is "undoubtedly" derived from the Scotch duddies (clothes) and that the term was originally gender neutral:
The word dude began to mingle in the speech of the people of this country about the year 1873, but did not make its appearance in print until 1876, when it boldly met the public gaze in the February number of "Putnam's Magazine." The origin of the word has been a question ever since it asserted itself in every-day speech, and its claim to represent a human nonentity in raiment befitting either fool or fashion-plate has never yet received the stamp of authority. The word is undoubtedly from the Scotch duddies (clothes), which crossed into England to become duds or dudes; and the first dude was what Shakspere calls "a clothes-wearing man." In Queen Anne's time he was known as a macaroni, one of the curiosities whom Addison described as "those circumforaneous wits whom every nation calls by the name of that dish which it loves best. In Holland they are termed pickled herrings, in France jean potages, in Italian macaronies, and in Great Britain jack puddings." In a play by Terence, the Latin dramatist, occur these lines:
Ila visus est
Dudum quia varia veste exornatus fuit,
which has thus been put in English:
He seemed a dude, because he was arrayed in a jacket of many colors.
This bears out the claim that dude is from the Scotch word duddies, clothes; and reminds me that the paragraph referred to above as having appeared in "Putnam's Magazine," February, 1876, is in these words:
Think of her? I think she is dressed like a dud; can't say how she 'd look in the costume of the present century.
So dude was once of the common gender; or, rather, there was a dud as well as a dude; whereas in our day the dude is of one kind only, and whether in social converse or in composition is not seldom represented by the neuter pronoun it.