Confucianism is a philosophical and ethical system based on the teachings of Confucius, focusing on morality, social relationships, and justice, while Legalism emphasizes strict laws and harsh punishments to maintain social order. Both philosophies emerged in ancient China, influencing its political structure, culture, and societal values significantly, often contrasting in their approaches to governance and individual behavior.