Flies are regarded by most people as a nuisance at best, a harbinger of death at worst. They elicit little more than feelings of disgust and many people are happy to kill them without a second thought. But there is another side to the story. The fly is one of nature’s great marvels and, perhaps, the criminologist’s best friend.

In addition to familiar forensic clues such as fingerprints, tell-tale hairs and bloodstains, more and more criminal investigators are relying on the services of the humble fly. Forensic entomology is the technical term for using insects to help us solve crimes. Given the nature of the things flies choose to dine on, they are often the first to be found at the grisliest of crime scenes. There is a predictable succession of flies that arrive at a corpse, with different species of fly specialising in eating different parts of the body at different stages of decomposition.

But this is not new science. Blowflies have been helping humans and our poor sense of smell for a long time now. A classic story worth retelling is about the first recorded case of forensic entomology in 1235, in a small village in China. A lawyer-cum-death-investigator called Sòng Cí wrote up the case in the medico-legal text book The Washing Away of Wrongs.

Poison tales: the chemistry of crime fiction – Science Weekly podcast Read more

A farmer from the village had been killed with a hand sickle, and Sòng Cí realised there was a cunning way to find the murderer. He asked for all the farmers to attend a meeting and to bring their sickles with them. He then had them wait. They did not have to wait long as the day was warm and flies soon started appearing. And these flies all went for the same sickle. Sòng Cí confronted its owner, who was so shocked that he confessed. What the killer had not known was that although he had cleaned the weapon of all visible signs of blood, the flies would still be attracted by the minute traces remaining on the weapon.

Eight hundred years later, flies were used once again to legally incriminate a murderer, this time in the UK. At the Natural History Museum there is a famous jar of maggots – a sample from the first criminal case where they helped convict a murderer.

The story begins with Dr Buck Ruxton, who was a practising GP in Lancashire, England, during the 1930s. He was generally well-liked and respected in the community where he lived and worked. Then, in September 1935, two mutilated female bodies were discovered wrapped in newspaper in a small ravine in Dumfriesshire, Scotland, 100 miles north of where he lived. Though the newspaper used was a national one, one of the pages used was from a supplement only available in an area very local to where Ruxton lived. And when it emerged that Ruxton’s wife and maid had disappeared, suspicion inevitably fell on him. He denied any involvement, claiming that the maid had fallen pregnant and that his wife had gone away with her to assist with an abortion.

But two key pieces of forensic evidence found him out. First, a comparison of images of one of the skulls with photographs of Ruxton’s wife pointed to one of the bodies being hers. Second, a sample of maggots collected when the bodies were discovered was sent to Dr Alexander Mearns, an entomologist at the University of Edinburgh. He identified them as Calliphora vicina, a very common carrion blowfly, and he was able to establish that they were somewhere between 12 and 14 days old, which meant that the bodies had to have been there for at least two weeks. This provided vital information as to when the murders took place, coinciding with when Ruxton claimed his wife and maid had gone away. Coupled with other evidence, it was enough to lead to his conviction and hanging.

Our understanding of forensic entomology has increased greatly over the past 80 years. In the US there are numerous body farms where donated human bodies in various states of dress are placed in various positions and locations and insect succession is studied.

What lies beneath: Sydney gets the southern hemisphere's first 'body farm' Read more

In Australia the first body farm has just been set up in the Blue Mountains near Sydney, currently the only facility outside the US.

Body farms are a perfect way for us to study the various factors affecting decomposition – in the outdoors, out of the way of curious humans and hungry vertebrates – and enable us to understand how long different stages take. A body that has been hung, for example, decomposes differently to one placed in a bin. Instead of decomposing, the suspended corpse becomes leathery, almost tanned, with very little maggot infestation even after a lengthy period of time, as the maggots are not able to attach to and infest it.

As well as position, the succession of feasting maggots can be affected by many external factors, such as temperature or the presence of narcotics.

Back in the late 1980s, Dr Madison Lee Goff, a Hawaiian forensic entomologist, received a phone call from another entomologist who had maggots from a woman who had been stabbed to death. Oddly, the maggots were of different sizes and so appeared to be of different ages – making the time of death difficult to determine.

Goff was, at that time, investigating the effect of drugs, specifically cocaine, on maggot development. In his book A Fly for the Prosecution he explains how he had to apply to his workplace for permission to give cocaine to rabbits and then go about trying to legally purchase the product. He eventually did get permission but then had to rely on donations from police agencies instead of buying it himself.

When he received this call he immediately thought about cocaine but, he admitted later, it was a long shot to ask if the victim had been tested for drugs. Cocaine is a strong stimulant, usually taken nasally, which in humans can produce a feeling of euphoria as it mimics adrenaline. Goff found that maggots subjected to cocaine grow more rapidly in comparison to their clean-living companions because of this stimulant. On investigation there were indeed traces of cocaine in the body and the larger maggots were found specifically around the nasal region.

Thanks to his research Goff was able to determine how much time had elapsed since the woman’s death, using both the development of maggots under the influence of cocaine and those developing naturally. From this they were able to establish when the victim had died, which had previously been a confusing element in the case. This new timeline was consistent with the other non-insect evidence and linked her killer’s activities to hers.

For as long as humans have been around, flies have been the unsung heroes who rid our environment of all kinds of rotting carcasses – dirty work essential to maintaining a healthy ecosystem. Now, thanks to their habit of dining on us when we die, they are unwittingly helping to make our world a safer place as well.