The TL;DR is that a PIs job security, promotion prospects and grant funding is unfortunately based not on the quality of the research they produce, but on the prestige of the journal they publish it in. To pass probation on my position I needed a publication with Impact factor > 10 within three years of starting. To keep my job I need a so called 4* paper once every 5 years.
There are two separate costs to publishing in many journals
- Open access fees
- Page charges/article processing charges
Open access
In general there are two sorts of journals - journals that are funded by the authors paying (open access) and journals that are funded by subscribers paying (closed access). Things are muddied by the fact that most closed access journals will allow authors to pay for Open Access for their paper, while most papers are closed (so called Hybrid journals or Gold open access)
Many of us page open access fees as a moral/ethical decisions - we believe it is wrong for research, that the public has presumably paid for, either through taxes to government agencies, or through donations to charity, it in accessible to the same public, as well as inaccessible to colleagues at less well funded universities.
However, moral issues aside, almost all funders in some fields, like medical research and life sciences, now mandate open access publishing. In some cases the funder will provide a mechanism for funding open access publication.
In the UK, every 5 years there is the Research Excellence Framework assessment, where the government assess the research success of every university and gives funding on the basis of this. This can be quite a lot of money (its about 20% of my universities income i think). They make this judgement on the basis of open access papers only.
But this doesn't explain page charges.
Page charges/APC
These are a relic of the days when it cost journals for every page/colour figure you had in your paper. You'd generally get a certain number of pages or b&w figures for free and had to pay more if you wanted more or colour. This no longer applies, but journals still like to charge it as its a nice little earner. The last paper I published charged $2,500 in page charges on top of the $2,500 open access charge. Why would you publish in a journal that has such charges? All the top journals have them. For the reasons I stated at the top - as a scientists you are generally judged on where your papers are published because those judging either don't have the time, the skill or the motivation to judge you on the content of your papers - you need to publish in top journals.
Paying these fees can be a real problem - the total $5,000 for my last paper was 25% of the total none staff budget of my lab at the time. You are generally not allowed to pay this out of grant money (which begs the question, what money is there that isn't grant money?).