Would it ever occur, historically, that a PhD student could not obtain his degree from a university due to the high costs of publishing his thesis, such that he would have to publish it at another university and get his degree there instead?
Emphatically, I don't see how this could happen in any subject in the U.S., nor, to my knowledge, in Europe, though I understand that there, in some cases, the actual work can be viewed as somewhat disconnected from a university.
But the point is that, in most subjects in the U.S., for example, one is not required to "publish" one's thesis in any fashion that would incur great expense. A handful of required copies, often printed nearly-for-free, and everything else is optional. Not "page costs" to journals, for example.
Further, in the U.S., it would be essentially impossible to "change universities" for any reason whatsoever, without re-doing many required activities, time-in-residency, and such. So whatever other advantages, there'd be something like a two-year delay, tuition, other things.
I really think that the question's hypotheses are iffy, possibly due to a misunderstanding of how things work. Certainly in the U.S., most likely in Europe, and I'd be surprised to hear that the questions implicit assumptions made sense anywhere in the world (though I'd certainly be interested to hear about such a thing).
When my parents were students in Germany (1930's and 40's) and probably for a long time before that, doctoral theses had to be published, either privately at the student's expense or in a journal. Because of the cost of private publication, students had a strong incentive to write a thesis good enough to be accepted by a journal. (And there were far fewer journals in those days.)
That information came from my parents. I don't think they mentioned how many copies would be required in the case of private publication, but I'd expect it would be enough copies for quite a few libraries. Journal publication was not associated with a university, so there was nothing to be gained by changing universities.