You see many pictures of spacecraft being handled by people with masks and hairnets. What's the reason for this?
You're right about clean rooms not effectively protecting against bacteria. So why are they used?
First, there are different levels of clean rooms. Typically the level is specified as a maximum number of particles per cubic meter (with different levels for different size particles). For instance, under the ISO standard, a class 6 clean room must not have more than 100,000 particles ≥0.1 µm, 23,700 particles ≥0.2 µm, and so on (for quick reference, see Wikipedia).
The "cleanest" clean rooms (lowest number of particles per unit volume) are used when the satellite has sensitive optics or other instruments on board. Cryogenically-cooled instruments are particularly susceptible to particulate contamination. Obviously if you have components that are very sensitive to contamination you want to keep your entire spacecraft free from possible contaminants, thus the need for your entire environment to be as clean as you can get it.
The "less clean" clean rooms (higher number of particles per unit volume) are for when you don't have components that are highly sensitive to contamination, and you can afford a few particles per square cm of surface area. While instrument performance may not be adversely affected by the presence of contaminants, you still want to keep the amount of dust and debris to a minimum to protect against possible electrical shorts or electrostatic discharge (ESD).
No specialist I, but I would argue the cleanliness becomes essential for at-least two reasons as follows -
- Contamination: Even the air we breathe is filled with bacteria, and what-not. Spacecraft sent on scientific missions could potentially return a false positive at the least. Worse, assuming life existed on the target body, Earth bacteria could easily do something they ought not.
- Risk: Dust may be susceptible to charge. In gravity, such dust would settle at the point of largest attraction. In a vacuum, dust would be free to potentially short out a micro-chip, or a PCB track ... whatever. Thus posing a hazard to the mission.
Ergo, we err on the side of caution by clean-room assembly.