The appearance of the detective in real life and in fiction seem to me to be entwined. The autobiography of the great French thief taker Eugene Francois Vidocq seems to have been an influence on both the establishment of the first detective unit in Britain and in Edgar Allen Poe's creation of what many argue is the first literary detective, Auguste Dupin in Murders in the Rue Morgue, published in 1841. The first detective department in Britain was created in 1843.
Detectives quickly started popping up everywhere – Dickens was a big fan of the real life and fictional detectives, and packed his monthly magazine All the Year Round with fictions and features on the new agents of order.