Because it's not about how expensive it is to actually make the drug. To use a software analogy, Oracle doesn't price their database software by what it costs in bandwidth for you to come to their site and download the latest version. Or in the days of shrink-wrapped software, the cost of software was far from the cost of the materials (cardboard and discs).
Books similarly aren't priced based on the cost of printing and distribution.
The cost is directly related to recouping R&D costs as well as the clinical trials. In addition, with these therapies specifically, you actually have pay lots of highly trained people to administer them in the first place.
In some cases (and you left out marketing, which often exceeds the R&D costs). In other cases, the cost is directly related to 10% less than other treatments. Or to whatever the CEO thinks he can screw out of patients. See: Shkreli; Epipen.
I disagree with your statement "in some cases". It's "most cases" and where it is not, those are the ones that get the attention and screaming headlines. Shrekli is in the news precisely because this behavior is not normal. But generally, much like other goods, drugs are priced based on how much the consumer values them. I will also add, that for really big ticket things like oncology drugs, I believe every company offers payment assistance programs which often have very high income cutoffs that provide co-pay help or outright free drugs when insurance doesn't cover it.
Marketing is a red-herring. Sales and marketing should bring in more money than you spend on them or they're not worth doing. They exist to drive money This makes the company more profitable in the near term than R&D expenditure which can take decades to materialize.
Books similarly aren't priced based on the cost of printing and distribution.
The cost is directly related to recouping R&D costs as well as the clinical trials. In addition, with these therapies specifically, you actually have pay lots of highly trained people to administer them in the first place.