Natural selection certainly operates. It explains how bacteria will gain antibiotic resistance; it will explain how insects get insecticide resistance, but it doesn’t explain how you get bacteria or insects in the first place.