Confucianism arose out of a period of civil war known as the Warring States period in the 400s BCE, beginning about 475 BCE. As the Zhou dynasty collapsed, warfare and barbarism spiked. Wanting to counter this, Confucius developed an ethical system that would bring order out of the political chaos.
Confucius believed that the confusion of his time period arose out a need to rightly name and order the relationships that held a family, society, and state together. He developed an ethical system that emphasized how relationships should be organized. One fundamental concept was the Five Bonds, in which the populace respected and deferred to the ruler, wives obeyed husbands, children obeyed parents, younger brothers deferred to older brothers, and youth deferred to elders (sometimes referred to as the older friend/young friend relationship). Strongly associated with these bonds was an ethic of filial piety, in which the superior person in a relationship was duty-bound to responsibly care for subordinates.
This system was outward or form-oriented: Confucius believed if people knew and followed the outward social norms, inner peace and harmony would follow. This system was accepted by leaders and people tired of warfare and produced a blueprint for social order that lasted some 1,500 years as the accepted organizing system for society.
Confucianism built on the moral basis through which the Zhou dynasty had legitimized its power, so it was an extension of an already existing political ideology. It spread widely and became popular because it opened avenues to power based on merit and virtue in addition to heredity.