Is there a logic to the way The LEGO Group fills the plastic bags?
The main goal is certainly packaging efficiency (possibly where parts come from in the factory, for example), but there are other factors coming in.

Sets which have "modular" building need to have numbered bags, and the numbering has prioity on other considerations — you'll need all bricks for module 1 to be in bags numbered "1" (plus sometimes, unbagged parts).

Also, elements which are too similar are usually in different bags. This helps finding them when building, but another reason for that might be the random checks which are done on bag contents during the packaging process, as I believe these are manual.

Sometimes, if an element is in huge quantity in a set, it can also get its own bag; and as jfyelle says, sometimes a same bag can appear twice in a set — it's easier for packaging than two bags with different contents.