Perhaps for a beginning we should really consider what detective fiction is. A reasonable definition would probably be that it would be a story depending on the investigation of a crime, mostly, but not always a murder. By simply a detective who in the early days would usually be a given amateur of independent means. https://www.youtube.com/watch?v=8etze8eF2KU
Probably, in the larger realm of general criminal offenses fiction, detective fiction is the most popular, incorporating mystery, intrigue, all elements of society, and any physical background you could think of.
As well as independent means, the first popular fictional investigators would be somewhat unusual, and possess at least a few character flaws to get them to interesting (Sherlock Holmes’ drug habits for example). They might often have an assistant (Dr. Watson for Holmes), who does be devoted, staunch, and a little slow on the subscriber base, although by no means stupid. The assistant would come in helpful for talking over theories, and through that character, outlining what you should the reader.
This is generally accepted that the first “modern” investigator story on these lines was “The Murders In The Rue Morgue” by Edgar Allan Poe, posted in 1841. In this short story Poe presented his detective C. Juste Dupin. Genius and unusual, Dupin is generally thought to be the motivation for Sir Arthur Conan Doyle’s Sherlock Holmes. Poe worked to a solution which has been used, with a few changes every now and then, ever since. The hero must solve whatever mystery is offered by using logic, remark, and occasional flashes of intuition.
The authorities are usually described as ineffective bunglers, who after a few false trails, often involving accusing the incorrect person, grudgingly accept the help (interference) of the lead charcter. Who magnanimously solves the case, and lets the authorities take those credit. Although the key characters and the target audience are left in no doubt as to who is very responsible. On occasion the detective will agree to a cost from a rich client, but actually will more usually turn it down with simply a touch of arrogance.
Sometimes in the first days of private eye fiction authors would use real life events as inspiration for a story. One such, was the infamous case of the murder of Mary Cecilia Rogers in New Hat in 1841. It had been a brutal murder, her body found floating in the Hudson River, previously being put through to considerable violence. No-one was ever brought to be the cause of her death. Edgar Allen Poe used this story for the most basic of his second narrative featuring C. Auguste Dupin. He changed Mary Rogers name to Marie Roget, transporetd everything to Paris, france , and had Dupin solve the case.