Ratchet is a slang term with multiple meanings, both negative and positive, all depending on the context and the attitude of the speaker.
On one hand, the original meaning of the term “ratchet” comes from the misspelling of the word “wretched” and has similar meanings, targeting women especially, describing them as uncouth, without manners and derelict.
Since the initial uptrend of the slang however, “ratchet” had gained additional connotations, sometimes used in situations where it describes someone as cool or exciting.
The most probable place of origin for the term “ratchet” is in Shreveport, Louisiana, that is known for being called “Ratchet City”.
The expression had been featured by local rappers in their songs since the 1990’s, most likely due to the local mispronunciation, that turns wretched into “ratchet”.
“Ratchet” only retained its negative meaning at that time, applied to someone classless.
The slang term started to take off in more and more rap songs since 2005, reaching its peak in popularity in 2012, when musicians like Nicki Minaj, Juicy J as well as LL Cool J featured the term in their songs.
It was around that time, that the word had gotten its secondary, more positive meaning.
Urban Dictionary has a lot of diverse definitions on the subject, since at least 2005.