How did modern western post-secondary education become tied up with research and publications? Teaching, research and (academic) publishing are three different pursuits. Our society and its institutions, particularly most universities, enforce links between these in various ways.

People who have great teaching skills can not get teaching positions (at universities) because they aren't good in doing research, and some potentially great researchers experience setbacks in their academic career because they are horrible at teaching, and both can be penalized by failing to or poorly publishing their results.

How did this happen? Who does is benefit? How does intertwining these three requirements benefit the general knowledge and the academic community?
Ca. the 17th century, typically research, teaching, and religion were the functions of a European university. For example, when Isaac Newton wanted to become a professor at Cambridge, he asked the king for a special dispensation to be excused from taking holy orders. He was expected to teach as well as doing research, but was apparently such a bad teacher that he often lectured to an empty room.

During this period publication was not as emphasized as it is today. There were no academic journals in the modern sense. People communicated their results directly to their students, by letters to their peers, and sometimes by writing books. In some fields, such as alchemy, secrecy was the norm.

Presumably the reason that research, teaching, and religion were all linked was that the system evolved from medieval institutions, in which the literate class consisted mostly of monks. Part of their job was to preserve knowledge.

I think the more modern, liberal, and secular model is what's known as the German university model. It dates to the 19th century and was influenced by personalities like Friedrich Schleiermacher and Wilhelm von Humboldt. I think this was also the era when modern academic journals began to appear, and this was an important, positive development.

Some more modern phenomena in the US are research supported by grants from the central government; land-grant colleges; the delegation of a large amount of undergraduate teaching to part-time faculty; and the creation of community colleges, which have only teaching as their mission, not research.