If you look at the label, a typical pill contains a few milligrams of the active ingredient, something on the order of a typical grain of salt. The pill, on the other hand, is fairly large. This is done because it's hard for people to handle and take something the size of a grain of salt. What makes up the rest of the pill can make a lot of difference. Many pills have a geletin coating on them, for example. It seals the pill from environmental degradation and it makes it easier to swallow. But "geletin" can come from several distinctly different sources. If you happen to be allergic to one, then which brand of pill you get becomes very important.
Next time you're at the library, leaf through a copy of The Physician's Desk Reference. This is a huge book that lists all the pills and drugs that are legal to prescribe. For each drug it lists all sorts of facts and figures to help doctors figure out which one will be best for a given patient, what dose to use, etc. For each drug, it has a section that tells how the drug actually works... or at least it's supposed to. But, if the truth be known, a lot of 'em boil down to "we really don't know how this stuff works... but it seems to." This is one reason why drug research is so expensive. While the drug companies like to show you TV commercials of very intelligent-looking people in white lab coats working in very sterile-looking laboratories using very expensive-looking equipment starring at apparently very-complex computer models of molecules with the implication that these people are working very deliberately and know exactly what they're doing, the truth is that a lot of it is just trial and error*... mostly error... and error is expensive. Anyway, the other result of this is that while a formula for the drug may exist, that forumula may not enable you to exactly reproduce it because we honestly don't know exactly what about it specifically makes it work. So, while one company may duplicate the chemical and even do it in a less-expensive way, the "magic" may not be exactly there.
* I'm not suggesting that these people aren't very intelligent and don't know a lot. One of them is my sister-in-law.