This paper selects relevant data of A-share listed companies in China from 2009 to 2022 to empirically analyze the impact of the legal environment on the high-quality development of enterprises. The results show that the improvement of the legal environment can promote the high-quality development of enterprises. Further mechanism analysis shows that the improvement of legal environment can significantly promote the high-quality development of enterprises through reducing corporate debt financing costs, increasing enterprise innovation investment, and improving corporate information transparency. In addition, compared with enterprises in non-heavily polluting industries, CEO duality firms, small and medium-sized enterprises and high-tech enterprises, the positive effect of legal environment improvement on high-quality enterprise development is more significant in heavy-polluting enterprises, non-CEO duality firms, large-scale enterprises and non-high-tech enterprises. In the future, enterprises need to further enhance their awareness of the rule of law, optimize their debt structure, increase investment in innovation, and improve their information disclosure mechanisms. The government should continue to strengthen the construction of the rule of law, enhance market supervision, increase the transparency of law enforcement, and optimize government services. By working together, the government and enterprises can create a better legal environment to promote the high-quality development of enterprises.