The short answer to this is to say that the Panama Canal was built so as to shorten the time that it took ships to sail from the East Coast of the United States to the West Coast. This was important for both commercial and military reasons.
Before the Panama Canal was built, ships that wanted to sail from the East Coast to the West Coast had to go all the way around the tip of South America. It was possible for ships to stop at Panama or Nicaragua, unload passengers and/or cargo, and have those transported across land and loaded onto ships on the Pacific. However, this took up a lot of time as well. In addition, this was not possible for military ships since they actually had to travel from one ocean to the other to be effective.
The Panama Canal was built to solve this problem. It dramatically cut the time that it would take a ship to go from coast to coast or ocean to ocean. This allowed the US to expand its commerce and its military power.