The President is the head of the executive branch of the government. Article II of the Constitution starts with the words “The executive Power shall be vested in a President of the United States of America.”
The “executive power” includes the power to enforce the laws of the nation. Pursuant to that, one of the many agencies within the executive branch of government is the Department of Justice (DOJ). The DOJ is headed by the United States Attorney General appointed by the President and confirmed by Congress. That is Jeff Sessions. The second in command is Rod Rosenstein the Deputy Attorney General. Rosenstein was also appointed by Trump and confirmed by Congress.
In this instance, Rod Rosenstein actually appointed Mueller as Special Counsel because Sessions had recused himself from the Russia investigation. As the man who hired Mueller Rosenstein has the authority to fire Mueller. However, Trump has the power to fire Rosenstein and appoint someone in his place that will fire Mueller.
This is what Nixon did in the notorious “Saturday Night Massacre” to fire Special Prosecutor Archibald Cox. It “worked” in the immediate sense that Cox was fired (after Nixon went through firing both his Attorney General and Deputy Attorney General). However, the act turned Congress and the nation against Nixon, eventually leading to plans for his impeachment that compelled him to resign.