North and South America were arranged in nearly the same positions as they are today as far back as 20 million years ago. A significant difference was that they were separated by a deep open channel called the Central American Seaway.
There was no Panama, and no need for a Panama Canal, because there was clear sailing from the Atlantic to the Pacific.
Things didn't stay this way, however, because the Earth is a geologically active planet with shifting crustal plates. During the time period between 20 and 30 million years ago, the Pacific Plate collided with the Caribbean Plate, pushing magma to the surface to make islands in the sea, and eventually creating a land bridge between the two continents. The movement not only changed the land, it disrupted ocean currents, opened a door to species migrations, and probably altered the world's climate.
When the land bridge closed, equatorial waters could no longer mix. The Atlantic became saltier and the Pacific more dilute, creating a gradient that moves water in a giant loop around the globe today. Warm Atalantic water that used to pass through the gap moved northward, becoming the Gulf Stream. Scientists believe these changes created a warmer Europe and contributed to our recent cyclic ice ages.
The land bridge also opened the way for species to cross from one continent to the other. Deer, horses, raccoons, bears and the camel ancestors of llama moved south across the bridge. Anteaters, porcupines, opossums and armadillos moved north.
Unfortunately, many large South American species couldn't compete with the North American animals and became extinct, changing the ecology of an entire continent.