Uncertain; perhaps an alteration of queme. The English Dialect Dictionary has a citation of "quim and cosh" from 1723 which it glosses as "intimate and familiar". Compare also quaint, cunt. Derivation from Welsh cwm (“hollow”) is sometimes suggested, but the OED notes that this is "unlikely on both semantic and phonological grounds".