Calling someone a cynic is, at the root, calling them a dog. The ancient Cynics took the insult and wore it proudly.
The English word comes, through Latin, from Greek kynikos, "dog-like," built on kyon, "dog." Etymonline says it entered English in the 1550s for a member of the ancient school of philosophy founded by Antisthenes, a pupil of Socrates. The Internet Encyclopedia of Philosophy notes that even that founding story is controversial. Antisthenes is named as the first Cynic mainly by the later biographer Diogenes Laertius.
The most famous Cynic was Diogenes of Sinope. He mocked custom and ordinary shame, and lived so roughly that one account quoted by Etymonline has him sleeping in a tub. The philosophy encyclopedia uses the Greek word, pithos. The encyclopedia says the Cynics, most clearly from Diogenes on, embraced their canine title. In one well-known anecdote he introduces himself to Alexander the Great as "Diogenes the Cynic," which amounts to "Diogenes the Dog."
Why "dog" in the first place is the real puzzle. One explanation is behavior: the Cynics were coarse, surly and shameless in public, like stray dogs. Another points to the Kynosarges, a gymnasium outside Athens open to those who were not full-blooded Athenians, where Antisthenes is said to have taught. Its name contains the word for dog.
The two sources disagree on which is likelier. Etymonline favors the gymnasium and translates its name as "the Gray Dog." The Internet Encyclopedia of Philosophy calls that derivation suspect. It offers "White Dog," "Quick Dog" or "Dog's Meat" as possible meanings, and notes nothing firmly links any Cynic to the place. It suggests the name may have started as an insult aimed at Diogenes' way of life.
English moved fast from the philosophers to the attitude. By the 1590s a cynic was any sneering, sarcastic person. Cynical meant "resembling the Cynic philosophers" in the 1580s. By the 1660s it had its modern sense of distrusting other people's sincerity and motives. The modern cynic doubts everyone, which the original Cynics did too, though they also slept in a tub to prove a point.