1816, ornary, American English dialectal contraction of ordinary (adj.). "Commonplace," hence "of poor quality, coarse, ugly." By c. 1860 the sense had evolved to "mean, cantankerous." Related: Orneriness.
early 15c., cors "ordinary" (modern spelling is from late 16c.), probably adjectival use of noun cours (see course (n.)). Originally referring to rough cloth for ordinary wear, the sense of "rude, vulgar, unpolished" developed by c. 1500 and that of "obscene" by 1711.
Perhaps via the notion of "in regular or natural order," hence "common, vulgar" (compare the development of mean (adj.), also ornery from ordinary). Or it might be via the clothing sense, and the notion of "wanting fineness of texture or elegance of form." Or both, and there might be also an influence, via metathesis, of French gros (see gross (adj.)), which underwent a similar sense development. Related: Coarsely; coarseness.