In the real world, the germ theory of disease was only discovered in the 1800s, preceded by the theory of miasma and the four humors. Is there any way a civilization could have stumbled on this knowledge earlier, and what kind of environment/society is necessary for that discovery to take place?
Depends on the definition of germ theory. Does it need a concept of single-celled bacteria and non-self-replicating viruses?
- Start with a concept that dirt brings disease. They don't really ask why, it seems obvious.
- Add the concepts that animals bring dirt if they are not cleanly/cleansed. Dogs are OK if they are washed regularly, rats are not OK. This includes insects. Bees are OK, they live in orderly hives. Fruit flies are not OK.
- They note that there are big and small insects, from butterflies to lice. Lice range in size from 5 mm to 0.5 mm. Their eggs are smaller.
If a society concludes that there is no minimum size to disease-bearing insects, does that mean they have a germ theory?
- A culture of curiosity. (Islamic Golden Age or Europe starting with the Renaissance.)
- Knowledge sharing (aka "science") instead of researchers who horde their knowledge (aka "alchemy").
- A concentrated-enough energy source to have:
- Sophisticated metallurgy and metal-working, and
- sufficiently developed glass-making, which leads to
- Optics, which leads to:
EDIT: good ideas from user535733:
- Mathematics developed enough to have created statistical analysis.
- Enough wood/bamboo to make lots of cheap, durable paper.
- The industrial chemistry to whiten that paper, and
- make lots of ink, for
- Printing the results of epidemiological studies in Journals. (Another need for "knowledge sharing").
Bottom line is that the ancient culture won't be very "ancient".
I'm not sure whether it counts as theory, but there seem to be some psychological mechanism in religion development that mixes up goodness, religious purity and cleanliness.
I mean Baptism in Christianity... Ritual washing in Islam before prayer... Or Hindus that pilgrimage to wash in Ganges...
Yeah, there really seems to be some kind of automatic association.
If you want to have an ancient society that get such theory roughly right:
they have to have some vague commandment concerning cleanliness and purity
they should suffer from some parasitic disease and think in this direction
(But it would be like Democritus atom hypothesis - guess in good direction, but not based on any hard data https://en.wikipedia.org/wiki/Democritus#Atomic_hypothesis)
I've read a number of medieval medical treatises (for fun!). These writings tend to combine classical information, some practical experience, and random bits of info. I always get the feeling that they were so close to getting it. Cleaning hands before procedures is mentioned more than you'd think. The effectiveness of wine for cleaning wounds is remarked on in a medieval military medicine treatise. Of course there is crap (literal and figurative) mixed in with the useful stuff and a new practitioner coming upon the treatise has no way to judge.
In reference to @RonJon'a list Optics as a science did fairly well in the Middle Ages. Spectacles receive their first mention in the mid 13th century. Clockworks with gears start appearing in tows around that time as well. Paper as well though you could use wax tablets for note taking. (I just spent an hour collecting oak galls from fallen branches to experiment with medieval ink recipes.)
The sharing of good information is of course a limiting factor. Medieval Europe knew how to hold a conference, they did that all the time for Church Councils, but there was little will for a natural science conference.
A plausible way for this germ theory information to spread in a 13th century environment would be through a military campaign. A secular ruler would have a very good reason for useful information to be shared and used on his (elite) soldiers. As the physicians return home they'd spread this knowledge.
I'm not sure if the Middle Ages is ancient enough for your question for it is my lens of information.
People and their livestock have pests including those that make them (and their animals and crops) “sick”. People discover poisons to deal with them.
Some pests are tiny. In particular, some mites or aphids or other important pest for agriculture has two properties: it makes the crops wither rather than just looking chewed, and it’s so small that it’s near the limit of human vision: some people can see them, some can just barely notice dots if they are moving, others cannot see at all. And clearly the juviniles are too small to see.
So, people are aware of the idea that animals can be too small to see, with no known limit to how small they may become. And they are known to be some diseases.
Since the same idea of hygene and steralization seems to work to prevent disease, and that's how cleaning and killing tiny pests works. So it would be a hypothesis that many more (if not all) diseases are caused by pests too small to see.