1843, American English, unrelated to the term for excrement, instead it is from Louisiana French craps "the game of hazard," from an 18c. continental French corruption of English crabs, which was 18c. slang for "a throw of two or three" (the lowest throw), which perhaps is from crab (n.2), the sense in crab apple. The 1843 citation (in an anti-gambling publication) calls it "a game lately introduced into New Orleans."
"defecate," 1846, from one of a cluster of words generally applied to things cast off or discarded (e.g. "weeds growing among corn" (early 15c.), "residue from renderings" (late 15c.), underworld slang for "money" (18c.), and in Shropshire, "dregs of beer or ale"), all probably from Middle English crappe "grain that was trodden underfoot in a barn, chaff" (mid-15c.), from Middle French crape "siftings," from Old French crappe, from Medieval Latin crappa, crapinum "chaff." Related: Crapped; crapping.
Despite folk etymology insistence, not from Thomas Crapper (1837-1910) who was, however, a busy plumber and may have had some minor role in the development of modern toilets. The name Crapper is a northern form of Cropper (attested from 1221), an occupational surname, obviously, but the exact reference is unclear.
"act of defecation," 1898; see crap (v.). Sense of "rubbish, nonsense" also first recorded 1898.
[by extension fr Middle English crap, ''chaff, siftings of grain, residue'']