Why does the President as commander-in-chief of the armed forces?

Because the US Constitution states he is:

http://www.law.cornell.edu/constitution/constitution.articleii.html
Read Article II, section 2.
It's very clear.

The President of the United States is the commander-in-chief of the armed forces for a number of reasons. This authority is vested in the President by the U.S. Constitution. The framers of the Constitution intentionally established this role as a way to balance power between the executive branch and the military, and to ensure civilian control over the armed forces.

To understand the reasons behind this, we need to examine the historical context. At the time the Constitution was written, many of the Founding Fathers had concerns about the concentration of military power in the hands of one person or a small group. They feared that a standing army could be used to oppress the people and undermine the principles of a democratic republic.

By granting the President the role of commander-in-chief, they sought to ensure civilian oversight of the military. It was believed that having a civilian leader at the top of the military chain of command would prevent the military from becoming a separate, autonomous entity. This system also aimed to prevent military officials from making decisions that would impact national security and foreign policy without proper civilian approval.

Moreover, the President, as the elected representative of the people, is accountable to the citizens. By placing the commander-in-chief responsibility with the President, citizens have a direct say in military matters through the electoral process. This helps to maintain the civilian control of the armed forces while ensuring democratic accountability.

If you're interested in a detailed explanation of the commander-in-chief role, I recommend referring to Article II, Section 2 of the U.S. Constitution. It outlines the President's powers as commander-in-chief, including authority over the military, making treaties, and granting pardons. Additionally, studying the Federalist Papers, a collection of essays written by the Founding Fathers, can provide further insights into their reasoning behind this constitutional provision.