1610s, "a pun, a play on words," probably a diminutive of obsolete quib "evasion of a point at issue" (1540s), which is based on Latin quibus? "by what (things)?" Its extensive use in legal writing supposedly gave it the association with trivial argument: "a word of frequent occurrence in legal documents ... hence associated with the 'quirks and quillets' of the law." [OED].
Latin quibus is dative or ablative plural of quid "in what respect? to what extent?; how? why?," neuter of relative pronoun quis (from PIE root *kwo-, stem of relative and interrogative pronouns).
"equivocate, evade the point, trifle in an argument or discourse, turn from the point in question or the plain truth," 1650s, from quibble (n.). Earlier "to pun" (1620s). Related: Quibbled; quibbler; quibbling.