When something causes both an effect that was intended and some other effect as well, the unintended effect is a side effect. For example, the intended effect of the antibiotic erythromycin is to kill bacteria, but a side effect for me is that it makes me vomit.

"Side-effect" or "side effect" is a relatively recent phrase. It first appeared in a book title with Lewis Levin's Side Effects of Medication (Die Niebenwirkungen der Arnzeimittel) in 1881. The OED's first citation is from 1884 for the general meaning, and they didn't list the medical meaning until a supplement citing a 1939 reference book, Wright and Montag's Materia Medica (Pharmacology and Therapeutics, vol 10, 112); the same supplement's first reference to "iatrogenic" (medically-caused) illness dates from 1923. Edward Tenner argues that this is due to a change in the Western worldview and that before the 19th century, people saw all consequences as equal rather than "side" effects. Negative effects from a medicine were taken as proof that the desired changes in the body were taking place.

Edward Tenner, Why Things Bite Back: Technology and The Revenge of Unintended Consequences New York: Alfred A. Knopf, 1996.
The Oxford English Dictionary entry for "side-effect".