Who made the first detective story?

The earliest story where someone tries to solve a crime, or detect, is in the Thousand Nights and a Night, or the Sheherezade stories of the Arabian Nights, written sometime around the 9th century - the story is called "The Three Apples" and concerns a chest where a dead woman's body is found.

There are also many old tales from China (around the time of the Ming Dynasty) about a character named Judge Bao, Judge Di, or Judge Dee, who solves crimes - you can find English translations of some of them in a series by Robert van Gulik.

In the European, or Western world, detective fiction is often thought to have begun with Edgar Allen Poe's story "The Murders in the Rue Morgue," in which a character named August Dupin solves crimes - Poe used Dupin in several stories.