Antibiotics work to kill bacteria. Bacteria are single-cell organisms. If bacteria make it past our immune systems and start reproducing inside our bodies, they cause disease. We want to kill the bacteria to eliminate the disease.
Certain bacteria produce chemicals that damage or disable parts of our bodies. In an ear infection, for example, bacteria have gotten into the inner ear. The body is working to fight the bacteria, but the immune system's natural processes produce inflammation. Inflammation in your ear is painful. So you take an antibiotic to kill the bacteria and eliminate the inflammation.
An antibiotic is a selective poison. It has been chosen so that it will kill the desired bacteria, but not the cells in your body. Each different type of antibiotic affects different bacteria in different ways. For example, an antibiotic might inhibit a bacterium's ability to turn glucose into energy, or its ability to construct its cell wall. When this happens, the bacterium dies instead of reproducing. At the same time, the antibiotic acts only on the bacterium's cell-wall-building mechanism, not on a normal cell's.
Antibiotics do not work on viruses because viruses are not alive. A bacterium is a living, reproducing lifeform. A virus is just a piece of DNA (or RNA). A virus injects its DNA into a living cell and has that cell reproduce more of the viral DNA. With a virus there is nothing to "kill," so antibiotics don't work on it.
Here are some interesting links: