Though drug companies whine on about the high costs of research and production, they happily sell their products at low prices to countries like Mexico, where the price level is low, and to socialized countries like Canada, where price controls keep the price down. Allowing Americans to buy online from any country in the world would do a lot to bring down the high price of prescriptions.
Most of the drugs sold to Mexico cannot be legally sold in the US. The drug companies aren't stupid; they recycle the stuff that is not salable in the US (e.g. because it has expired per FDA regulations) and resell it in countries with looser guidelines. This fact is priced into the drugs when they are produced and sold in the US.