Actually, it doesn't. Both math departments I'm familiar with had faculty members who published only to get tenure, and never published again until they retired.
But if they didn't teach (or taught extremely poorly), they got fired, even though they had tenure. If you didn't show up to a scheduled class a number of times, you got in trouble.
I know you weren't saying this, but it's frustrating reading so many comments about mathematicians "getting paid to have fun and good riddance". No - the majority of what they do is teach non-math students. If people here don't like that, by all means dissolve the departments and have the engineering departments teach math.