Why were monks and monasteries important in the Middle Ages?

Monks in monasteries during the middle ages were among the few, like the nobility, who could read and write. Because of this, most of the knowledge was kept restricted to that small sect of people. It wasn't until Johann Gutenberg invented the first printing press in the 1450's changed the situation so that knowledge was made available to everyone, and that was the main influence that spurred on the Age of Enlightenment.

A case can be made that monasteries almost single-handedly saved western civilization. After centuries of civil war and corruption the Roman Empire slipped away into history when Odoacer deposed the last Roman Emperor in 476AD. Barbarian hordes swept over the west and razed the last vestiges of this once mighty empire, squabbling over its territories and scattered riches. Europe entered what is commonly called "The Dark Ages".
Most major city centers lay in ruins, however, monasteries, because they were remote and hard to access, remained and within them were retained the culture and book knowledge lost everywhere else. Monks relentlessly copied and recopied Greek and Roman manuscripts as well as holy books, thus keeping the kernel of future civilization alive. The monasteries also served as the vanguard of future civilization, for when a monastery was founded, people naturally flocked around it to enjoy its spiritual and material benefits, and very often, this served as the nucleus of a budding town - not a few cities came out of such humble beginnings. Monasteries were often check points for travelers, forts in times of conflict, distribution centers in times of famine, hospitals in times of sickness, neutral grounds for conflicting parties to voice grievances and make pacts as well as being bastions of knowledge and skill.
Certain orders of monks were missionary in spirit and it was they who went out to conquer the barbarians with religion rather than the sword. Through a long organic process, monks actually were heavily responsible for making The Enlightenment possible by civilizing the barbarian tribes whose progeny, in forgotten centuries later, would ironically claim the Church was barbaric. If you ask a Catholic, they call the Dark Ages "The Golden Age of the Church" because the Church acted as the sole light in that dark time, and the monks played a huge role, both strong and resolute, in bringing Faith and civilization back from the brink of extinction in the west.
What is often forgotten is that monks preserved knowledge, were inventors of rudimentary machinery, many alcoholic beverages and types of cuisine, basic science, preserved language and knowledge, tutored pagan chieftains who would begin the royal lineage of kings and the lords of established realms, encouraged agriculture and land development, re-established Latin as a universal language and made connections with one another, thus laying the ground work for a new system of European unity. Reading and writing was not seen as it is today, but was as much a tool as a plane was to a carpenter and a plow to a farmer; the oral transmission of knowledge and traditions was the common way of doing things.
Centuries of struggling for basic survival culminated in a slow recovery that finally bore fruit: civilization gradually reemerged. With civilization came a new leisure class, one that would challenge kings as well as the Church, for though it did not have power or nobility, it had money. This leisure class wanted power and influence and its members desired to have access to and develop the knowledge and ideas the monks had been maintaining for centuries. The Church had established by this time public universities open to those whose discipline was for things of the mind, which usually meant nobles, the emerging middle class and religious. The middle class, with its drive to carve a spot for itself out of medieval Europe, introduced a new aggressive spirit, which manifested itself as humanism in intellectual circles. It rapidly expanded upon ideas and thinking and was quick to harness print in order to disseminate its views far and wide with great alacrity. This sudden influx developed into The Enlightenment. The Enlightenment came to despise the monks for their caution and seeming lack of enthusiasm to push into new ways of thinking and experimentation and it resented that they strove to temper it with their ponderous doctrine and moral considerations. It was ultimately a culture clash more than an issue of Faith, and ultimately, the monks were forgotten and sometimes killed in the revolutions that would later result. The Enlightenment was very much a bourgeois phenomenon, for it did not help the common man; farmers still farmed, tradesmen still plied their trade with very little of what we would call education.
For centuries, the monks coaxed civilization back from the ashes of the Roman Empire. Eventually, a new and safe society emerged that allowed for profitable trade and business, and the monks were discarded. These days, the monks are largely discredited, if they're even mentioned at all. The monks have stuck to their monasteries, as they had in centuries past and as they still do, bastions of the Faith and time capsules of knowledge should the west crumble again. To this day, however, the Enlightenment and its children have forgotten their roots in the ancient monasteries in Europe.