Why is it so legal for lawyers to take commission in litigation?

When handling legal affairs, it is legal for lawyers to charge a certain percentage of remuneration according to the amount of property involved in related affairs, but it should be stipulated that risk agency is not allowed in some cases. Such cases involve personal relationships (such as divorce cases, alimony, alimony and criminal cases), because such cases may affect social welfare and social justice in addition to their own interests.