Because the European society of the Middle Ages lacked so many of the institutions that we now take for granted, monasteries played many roles that were very important. They played roles that had to do with social services, with education, and with the spread of Christianity.
Monasteries helped to spread Christianity. We think of Europe as a Christian region, but this was not necessarily true in the early Middle Ages when there was still a great deal of paganism. The monasteries helped spread Christianity among these people. This was important because it helped to create a more united culture in Europe.
In medieval times, governments typically lacked the resources and/or the inclination to provide much in the way of services for their people. Monasteries picked up the slack in this regard. They had money because of the lands they controlled, but they did not have as much need to spend their money on things like armies or luxuries. Therefore, they could use it to help the common people. They created orphanages and hospitals and other types of institutions that could help people who were in need.
Finally, the monasteries were the main source of education in early medieval Europe. It is said that the monasteries saved classical learning by keeping and copying old texts. They also taught people to read and write. This provided (according to p. 313 in the Brief Second Edition)
a source of literate, educated, and talented individuals whose … services were crucial for the organization of effective government in early medieval Europe.
Thus, monasteries played many important roles in early medieval Europe.