There was an interesting BBC series about that.
It explored how the modern pharmacy (drug store) came about and how they contributed to an awful lot of modern things! Providing raw chemical ingredients was basically how they started and this survived for a long time as this quickly developed into medicines and then other things like cleaning chemicals and dyes.
Fun fact! Ever wonder why it was the drug store you went to to develop your camera film? Because it was a process that needed specific chemistry. And that was expertise the drug store had in a retail environment. Obvious really. :)
Wade.