The study of chemistry is integral to the study of pharmacy, since pharmaceutical science studies how different medications react chemically with the chemicals within the human body. Life itself can be summarized as the sum total of chemical reactions within an organism. Pharmaceutical substances are designed to control or otherwise alter those reactions. Pharmacists are experts in dosages and related topics, while pharmaceutical science studies the chemistry.
Pharmaceutical compounds are only effective insofar as they affect targeted chemicals in the body, but they rarely only affect one. These side effects are almost never beneficial. As such, the compounds used in medications are strictly controlled in their composition and in their amount. Every medication and condition aims for a particular concentration of the compounds in the body, so the dosages must be controlled. Generally, dosages are affected by the severity of the condition they treat and the body size of the person to whom they are administered.
The chemistry of complex organisms like humans is so complicated that scientists only have a very partial understanding of it. While pharmaceutical compounds must undergo several rounds of testing before being released, unexpected effects are often discovered long after the release of a drug.