There are at least two ways to answer this question.
First, we can ask what legal authority gives Congress the power to regulate these areas of the economy. The answer to that is the Commerce Clause. The Commerce Clause is found in Article I, Section 8 of the Constitution. It says that Congress has the right to regulate any commerce that happens between the various states. If some form of business takes place only within a state, Congress does not have the right to regulate it. However, if the business is conducted across state lines, Congress does have the right to regulate it. This clause of the Constitution is what Congress relied on to take the power to regulate the forms of commerce that you are asking about.
Second, we can ask what caused Congress to start regulating these parts of the economy. The answer is the Great Depression. Before the Depression, Congress did not regulate the economy very much at all. When the Depression hit, the economy suffered so badly that people wanted the government to do something new. They elected President Franklin D. Roosevelt in 1932. He promised a “New Deal” for the American people and his New Deal involved new forms of government regulation.
During the New Deal, people sued the government, claiming that the new regulations were unconstitutional. They pointed out, for example, that children working in a factory did so only in one state and that their labor could not be regulated by the federal government. However, the Supreme Court eventually ruled that the factory was part of interstate commerce because the materials used in the factory could come from out of state and the factory’s products could be sold out of state. This gave the Congress the right to regulate child labor. The same logic was applied to the other parts of the economy that Congress regulated.
So, we can say that Congress got this power from the Commerce Clause and the Great Depression.