What happens to unproductive professors?
This depends on a lot of things, including how you define productive. I think you mean "produces publications", but there are other definitions. In particular, some professor who hasn't done a lot of recent research, but is otherwise well known, might, on the basis of letters of recommendation, send a lot of undergraduates to great doctoral programs. That would be highly valued in some institutions, especially small ones. In some other places, grants received, measured in dollars/euros/krona/yen/..., is the main measure of productivity. 

While there are many (many) exceptions to the following, in general, assuming this is the US, an Assistant Professor who isn't productive won't get tenure and will likely not advance in an academic career. A tenured Associate Professor won't be advanced to Full Professor and will receive only minimal raises over the remaining career. S/he might be a bit ostracized by colleagues, but that depends on other aspects of "productivity". A Full Professor will probably only get minimal raises, but might be able to use such things as textbook revenues or consulting to supplement a relatively poor salary. 

My experience was mostly in Professional, not R1, universities. Where I worked we had a sensible system in which a Professor (even a Full Professor) was evaluated each year. The professor was allowed to set the terms of the evaluation, within limits. The stated "things of value" were Research, Teaching, and Service. Different universities will value these differently at different times and an individual can also value them differently as their career progresses. 

But the process might work like this: The professor writes an annual dossier in which s/he comments on contributions to the main criteria, and others if desired. This dossier is a few pages and lists papers and conference talks, grants, professional contributions (conference chair...). It discusses contributions to teaching, such as courses developed or improved. It also discusses, as appropriate, service to the university, its students, and the general community. The dossier can also include a suggested plan for the coming year mentioning each category. 

Then, after the dossier is submitted, someone, such as the Dean, reviews the dossier and comments on it. Some of the comments are laudatory and others point out places where the "contributions" are less valuable as seen by the university at that moment. The reviewer will also suggest a plan for improvement, if necessary, that becomes an expectation for the following year. For a tenured professor, the job itself isn't in jeopardy, but the level of compensation normally is. But the university also sets ranges of possible changes in compensation and the bottom is normally greater than zero. Actual reductions in salary would be rare, and possibly illegal. But inflation catches up pretty quickly if your salary is stagnant. 

I consider this to be a reasonable evaluation plan. In an R1 university using such a plan, research would be the category most valued and most weighted by the reviewer who looks at the dossier. In a teaching university or college, Research would be expected, but at a lower level and teaching and service to students (especially) would be more highly valued. 

But the beauty of the system is that an individual initiates the evaluation and can establish their own "most valued" contribution and, while it can't ignore the value system of the university, need not adhere to it absolutely. For a university, even an R1 university, it isn't necessary that everyone treat research as the most important thing at every point of the career. There are other things of value and other sorts of valued contributions. Carl Sagan, for example, may not have done a lot of research in later years, but was highly valued by Cornell and others. It is enough, for the university, that all of its goals are met and that overall, there is a good balance (as defined by the university) between the valued elements. 

In fact, it is possible that a Dean in trying to optimize something like research contribution at a micro level, actually sub-optimizes it at a macro level, creating an unhappy and unproductive environment. 

Of course, some people get lazy as they grow older. But if you have a valued position at any kind of university it is probably true that your personal goals align pretty well with those of the university. You do what you love to do and it is just about what the university wants to see done. So there is a lot of personal drive, even inertia, to keep doing that. If you've been doing research since forever it is likely that you love it and want to continue doing it. For many people, it is harder to get them to stop than it is to get them to do more.