Gizmodo recently had the chance to visit the Lego factory in Sweden(?). I have always been enthralled with Legos and have fond memories of building all kinds of things growing up. One of the most interesting things about Legos is that I never heard of anyone every missing a part in a set. This is an amazing accomplishment given the complexity of Lego models.
In the article above, Gizmodo talks about Legos manufacturing process. One of the coolest thing is that the article includes numerous videos and Lego was very open out their processes. This is very refreshing given that so many companies are so secretive about how they do things these days.
The short answer the question about how they manage to have all the parts included in every package, is that the entire process is highly automated. Machines pick and place the appropriate parts in bins and these bins are measured by extremely accurate scales and the weights are matched to the known weight of the kit. It is actually a highly detailed process.
Kudos to Lego for letting Gizmodo visit and providing such good information!