This is due to mutations or an environmental change
Causing different characteristics
If beneficial, the organism will breed and pass it on. If not it will die.
Over time, the species evolves and can even create new species
The theory of natural selection was only gradually accepted because it challenged religious beliefs, not enough evidence and inheritance and variation werent know yet.
Resistant organisms prove Darwin's theory. When antibiotics are used, some of the bacteria are already resistant so are more likely to survive and reproduce passing on the resistance gene.