Do you know ghouls from goblins and ghosts?
1706, "debauched, disreputable," from rake (n.2) + -ish. Related: Rakishly; rakishness.
The meaning "smart, jaunty, dashing" (1824) is said to be a different word, probably from rake "slant, slope" (1620s), used especially in reference to a ship's hull or sails, of uncertain origin, perhaps from Scandinavian (cf. Old Swedish raka "project, reach;" Danish rage "protrude, project") related to Old English reccan "stretch." "The piratical craft of former times were distinguished for their rakish build" [Century Dictionary].