In simple terms, it was the skinniest place between North & South America. But MAINLY: In order to connect the Pacific & Atlantic oceans so boats don’t have to travel all the way around South America to reach either ocean.
BONUS: It was put into motion by Theodore Roosevelt & was highly successful financially as well as intent-wise.