Antibiotics, as the name implies, work against life, or more specifically against living cells.
Since our bodies are also made up of living cells, the antibiotics have to distinguish between the cells in our bodies and the cells of the bacteria causing the infection or disease.
A Strong Cell Wall
To see how antibiotics recognize bacterial cells, we have to know something about the difference between those cells and the cells in our own bodies.
One of the differences between bacterial cells and animal cells is that a bacterial cell is surrounded by a strong "cell wall."
When a bacterial cell reproduces, the cell wall stretches and grows until the single cell is big enough to divide in two.
Then the process begins again and those two cells divide into four. So in order to reproduce, the bacterial cell has to be constantly building new cell walls.
How Antibiotics Work
The way penicillin and some other antibiotics work is by do stopping the growth of cell walls.
These antibiotics bond to protein molecules on the existing wall and prevent the cell from adding any new material as the wall stretches.
When the cell wall stretches too far, it becomes weak and eventually bursts, destroying the cell. Since animal cells don't have cell walls, they are not affected by penicillin.
Attacking Bacteria Cells
Not all antibiotics work the same way, but to protect a human or animal body, an antibiotic has to attack bacterial cells in some specific way that won't damage animal cells.