"Man's best friend" is a common phrase about domestic dogs, referring to their millennia-long history of close relations, loyalty, and companionship with humans. The first recorded use of a related phrase is by Frederick the Great of Prussia. It was likely popularized by its use in a poem by Ogden Nash and has since become a common colloquialism.
Before the 19th century, breeds of dogs (other than lap dogs) were largely functional. They performed activities such as hunting, tracking, watching, protecting and guarding; and language describing the dog often reflected these roles. According to the Oxford English Dictionary, “In the oldest proverbs and phrases dogs are rarely depicted as faithful or as man’s best friend, but as vicious, ravening, or watchful.” Beginning in the 18th century, multiplying in the 19th and flourishing in the 20th century, language and attitudes towards dogs began to shift. Possibly, this societal shift can be attributed to discovery of the rabies vaccine in 1869.