Three offices of Joseon
Three Offices, or Samsa (삼사·三司), is a collective name for three government offices in Joseon Dynasty that functioned as major organ of press and provided checks and balance on the king and the officials. These were Office of Inspector General (Saheonbu·사헌부), Office of Censors (Saganwon·사간원), and Office of Special Advisors (Hongmungwan·홍문관).
While modeled after Chinese system of Censorate, they played much more prominent roles in Joseon government than their Chinese counterparts. Some historians credit Three Offices for absence of abuses by eunuchs that were prevalent throughout Chinese history. 
The officials who served in these offices, called "daegan" (대간), tended to be younger and of lower rank compared to other offices such as Six Ministries but had strong academic reputation and enjoyed special privileges and great prestige. To be appointed, they went through more thorough review of character and family background. The children of officials who were impeached for corruption and children of concubines were excluded, and only those who passed literary gwageo examinations could become a daegan. As it attracted the elite of Joseon officialdom, Three Offices provided one of the fastest routes of promotion to top posts in the Royal Court and was almost a requirement to becoming a State Councillor.
Office of Inspector General
It monitored government administration and officials at each level in both central and local governments for corruption, malfeasance, or inefficiency. It was also in charge of advancing public morals and Confucian customs and redressing grievances of the populace. It was headed by Inspector General (Daesaheon·대사헌), who oversaw 30 largely independent officials. It is the largest and most senior office of Three Offices.
Office of Censors
Its chief function was to remonstrate with the king if there was wrong or improper action or policy. Important decrees of the king were first reviewed by censors, who could ask to withdraw them if judged improper. It also issued opinions about the general state of affairs. It was composed of five officials, led by Chief Censor (Daesagan·대사간).
While the primary focus for Office of Inspector General is the government officials and Office of Censors is focused on the king, two offices often performed each other's functions, and there was much overlap. Together they were called "Yangsa," (양사) which literally means "Both Offices," and often cooperated in joint actions especially when they sought to reverse the king's decision. In their role as organ of press, they did not have actual authority to decide or implement policies, but had influential voice in the ensuing debate. 
Office of Special Advisors
It oversaw the royal library and served as research institute to study Confucian philosophy and answer the king's questions. Its officials took part in the daily lessons called gyeongyeon(경연), in which they discussed history and Confucian philosophy with the king. Gyeongyeons generally took place three times a day although few kings such as Taejong and Yeonsangun abolished them. Since these discussions often led to commentary on current political issues, its officials had significant influence as advisors. It was headed by Chief Scholar (Daejehak·대제학), who served concurrently in another high post (such as in State Council), and Deputy Chief Scholar (Bujehak·부제학), who actually ran the office. There was great prestige attached to being Chief Scholar in this deeply Confucian society.
The office was established in 1463 by King Sejo to replace Hall of Worthies (Jiphyeonjeon·집현전), which he abolished in 1456 when many of its key officials ("Six martyred ministers") became involved in the assassination plot in their effort to restore deposed king Danjong to the throne.
Three Offices of Joseon was inherited from Goryeo Dynasty, but its characteristic features were developed after neo-Confucianism became the ideological foundation in Joseon, especially during Seongjong's reign.
Seongjong brought in a group of neo-Confucian scholars called Sarim as a new political force to check the power of ministers (called Hungu)who had accumulated great power and wealth by supporting his grandfather Sejo when Sejo usurped the throne from his nephew Danjong. With Seongjong's patronage, Sarim scholars occupied key posts in Three Offices and challenged the Hungu ministers who occupied key posts in State Council and Six Ministries. More significantly, Three Offices developed into a third base of power that provided checks and balance between the king and the ministers of State Council and Six Ministries. It could remonstrated with the king if it perceived that the king made a mistake had veto power against appointment of officials and enactment of laws including royal decrees.
The resulting conflict between Sarim fanction and Hungu faction led to two literati purges that decimated Sarim scholars and emasculated Three Offices during Yeonsangun's reign. Yeonsangun, who saw Three Offices as a threat to king's absolute authority, eliminated two offices - Office of Censors and Council of Special Advisors - and reduced Office of Inspector General. However, Three Offices was restored to its previous position when Yeonsangun became too tyrannical and was deposed in a coup.
Jungjong of Joseon, who succeeded Yeonsangun, again embraced Sarim scholars as a means to check powers of Hungu ministers who put him on the throne and thus wielded power that virtually superseded Jungjong. Again, Sarim scholars led by Jo Gwang-jo used Three Offices as power base to challenge Hungu ministers and launch a series of reforms. However, Jungjong was estranged from Jo Gwang-jo due to radical nature of his reforms and slander of the Hungu faction, which led to Third Literati Purge of 1519.
Traditionally, these purges were interpreted in terms of struggle between two rival factions - Sarim and Hungu. But some historians now view the purges as Joseon kings' campaign to weaken Three Offices, which emerged as a key player in the delicate balance between monarchy and bureaucracy/aristocracy that chraracterized Joseon.
- Kim Beom, Age of Literati Purges and Coup
- Yi Sang-bae, "Samsa", Dusan Encyclopedia
- Kim Beom, Age of Literati Purges and Coup