As others have pointed out, dust on the lens is not a big deal because it's far from the focal point. It's also usual that this kind of stuff goes on in a cleanroom.
However the lens does have to be made to very tight specs. If we are talking about laser scanning the type of lens is an f-theta lens (meaning that they focus the laser onto a flat plane), and they are usually telecentric (meaning that although the beam enters the lens at an angle it comes out perpendicular to the target, regardless of position.
It happens that I have been working on this type of system recently (not semiconductors but similar technology) and the lens quality turns out to be critical. Factors that do matter are having a focal length which remains constant, and focusing to a consistently round spot, across the field of view. That's what you pay the real money for.
If you are interested in the lens design, here is a nice explanation.