The main objective of the bowler is to obtain wickets. The batting order of a team is such that the best batsman make up the first 3-4 players (or top order) of the line-up.
The next 3-4 players consist of batsmen with reasonable batting abilities and the remaining player consist of unremarkable batsmen. The duty of the opening bowlers is to breakthrough the opening line up so that batsmen with lesser ability are exposed. Normally a fast bowler opens the bowling line-up. With the ball being new and hard at the beginning of the match it will zip through with a lot of bounce, this creates many wicket taking opportunities.
A good line and length ensures that the batsman is kept in check. An example would be waist high balls pitched on the offside between the batsman and his body where the ball isn't deep enough to play a shot off the backfoot and is not short enough to play off the front foot.
The other objectives of the bowler is to reduce the number of runs and extras given.
In ODIs the fast bowlers usually bowl the first 10 overs, whereas in test matches they bowl the first two hours, after which medium pacers and spinners are brought on. As there is less pace on the ball with these bowlers the batsman has more time to prepare his shots and therefore score more runs.
Using variety, the bowlers can stem the flow of runs as well as create opportunities for wickets by confusing the batsman with the flight, swing and spin of the ball. In ODIs these bowlers continue till about the 35th over after which the fast bowlers are brought back into the bowling attack.
This is because in an ODI, towards the end of the innings the batsmen are on the lookout to maximise the runs scored and will therefore, have a better chance to do so with the slower bowlers, because they are looking to take more risks. It is therefore wise to use a fast bowler as opposed to a slow one.
This period is ripe with opportunity to capture a wicket and to try and force a breakdown in the batting order. Bowlers often use the slower or faster ball to catch the batsman off guard. These deliveries are particularly useful to surprise the batsman, when the batsman has got into a rhythm and is expecting the same pattern to continue.
In a test match, where the overs are plentiful, there is no hurry to score runs. Therefore batsmen have to take fewer risks. The duty of the bowler is to try and obtain wickets because more wickets translate into fewer runs being scored over a long period of time.
The restrictions for wides are eased so that the bowler can afford to be less accurate. He is also allowed two short pitched balls per over as opposed to just one in ODIs. These balls can be used to unsettle the batsman and cause him to play a loose shot.