Sometimes the date/time of death can’t be established.
But often it can.
For example, heat loss from a body occurs at a steady and predictable rate. So, measuring the corpse’s temperature can help determine the time of death.
For bodies found outdoors, where insects have been very much involved in the decomposition (!), the type of insect/eggs found on the body is related to the time since death - certain insects are present only after certain periods of time since death.
For relatively recent deaths, the presence or absence of rigor (stiffness) also helps. I can’t remember the details, but rigor occurs only during a particular interval after death. So, if present, rigor narrows down the time of death considerably.