Snakes can traverse almost all types of environments by bending their elongate bodies in 3-D to interact with the terrain. Similarly, a snake robot is a promising platform to perform critical tasks in various environments. Understanding how 3-D body bending effectively interacts with the terrain for propulsion and stability can not only inform how snakes traverse natural environments, but also allow snake robots to achieve similar performance. How snakes and snake robots move on flat surfaces has been understood well. However, such ideal terrain is rare in natural environments and little was understood about how to generate propulsion and maintain stability in 3-D terrain, except for some studies on arboreal snake locomotion and on robots using geometric planning. To bridge the knowledge gap, we integrated animal experiments and robotic studies in three representative environments: a large smooth step, an uneven arena of blocks of large height variation, and large bumps. We discovered that vertical body bending induces stability challenges but can generate large propulsion. When traversing a large smooth step, a snake robot is challenged by roll instability that increases with the amplitude of vertical bending. The instability can be reduced by body compliance that statistically improves body-terrain contact. Despite this, vertical body bending can potentially allow snakes to push against terrain for propulsion, as demonstrated by corn snakes traversing an uneven arena. A snake robot can generate large propulsion like this if contact is well maintained. Contact feedback control can help accommodate perturbations such as novel terrain geometry or excessive external forces by improving contact. Our findings provide insights into how snakes and snake robots can use vertical body bending for efficient and versatile traversal of the 3-D world stably.