Multiple things lower the chances of it driving somewhere that would damage it, but of course things could still happen.
First, the project managers picked places that didn't have too many dangers, and they planned things out using orbital photos, etc. Then, they look at the landscape through the rover's cameras and plan a course that looks to be safe, and the rover also has autonomous driving sensors to help avoid things like cliffs and whatnot.