Legalism emphasizes the proscribing of laws in order to ensure public order, whereas Confucianism is more concerned with instilling morality. Both philosophies are very concerned with how to effectively govern a state, but they take very different approaches. Legalism favors a complex system of rewards and punishments to control human behavior, while Confucianism places importance on virtuous rulers who teach the people by example.
Legalism arose in response to Chinese rulers who desired to unify the country. The advisers who developed and systematized Legalism were interested in organizing society on a rational basis and placed great emphasis on strengthening the military and agricultural sectors. Ultimately, the Legalist solution was to highly regulate Chinese society and give harsh punishments for disobedience. This tendency culminated in the brutality of the Qin Dynasty. The oppressive force of the Qin led to the dynasty's downfall.
Confucianism's stance directly opposes Legalism. It is based on the notion that law without morality is a weak basis for society. If people are virtuous, there is no need for stringent laws. Confucius taught the importance of four virtues: sincerity, benevolence, filial piety and propriety. Whereas Legalists emphasized devotion to the state and subordinated religious rites and traditions to political sovereignty, Confucius espoused the necessity of reverencing ancestors though commemoration and ceremony.