A batsman isn't just trying to avoid getting out. They are also trying to score runs to help their team win the game.
A run is scored if the batsman hits the ball away from the wicket, and is able to run from one set of stumps to the other. Every time they make it, one run is scored.
If the ball crosses the boundary - a line around the edge of the field - without bouncing it is worth six runs, if it bounces first, then it is worth four runs.