Lǐ
Lǐ has a different meaning in both traditional Confuciansm and Neo-Confuciansm. But originally, it refers to rituals and religious practices. Lǐ already existed through largely etiquette among nobles, but Confucius expanded and reinterpreted Lǐ so it encompasses all forms of social conduct, not just organized religious rituals. The core purpose of Lǐ is to keep social harmony, especially with proper etiquette. Etiquette also gives one morality (Rén).
Sacred Lǐ
Sacred Li is all about ancestor veneration, imperial coronations and life ceremonies (i.e. weddings, funerals, etc.) to name a few. The reason for sacred li is to connect people to Tian or Heaven. It also reinforces the ancestor veneration and makes clear that an ancestor is placed higher on the 'hierarchy' of the family than a son.
Etiquette
Social etiquette includes but is not limited to bowing, giving gifts and language. Family hierarchy is extremely important in Confucianism and is shown through Li, which includes bowing, honorifics, and gift-giving to honor elders of the family.
Importance
Li is ethical training for the young, to show the hierarchy of the family. Children are immediately introduced to these concepts through honorifics, funerals (traditional mourning period where family pray for loved ones for prolonged amount of time).
Flexibility
Confucius said that yi takes precedence if one feels that adherence is conflicting with righteousness (e.g. an ancestor abusing their role).
By dynasties
Chinese emperors have historically used Li to their advantage to legitimize their rule through, for example, the sacrifices the emperor made to Heaven (kneel and touch the ground with one's forehead 9 times). Or the Mandate of Heaven, which meant that the current ruler was the sole ruler of China and that they were given authority to rule, directly from Heaven.