A double switch is typically used in situations where the designated hitter is not used and the pitcher is one of the players being substituted. The purpose of the move is to change the pitcher's slot in the batting order, so that the new pitcher does not immediately come up to bat in the next half inning. For example, if the left fielder, batting seventh, made the last out in the preceding half inning, a manager who wishes to change his pitcher in the middle of the following inning may elect to also change his left fielder, moving the new LF to the 9th slot of the order, and the new pitcher to 7th. This allows his team to have a better hitter coming up second in his team's next turn at bat, while not having to decide whether to pinch hit for his pitcher for a while.
As explained in paragraph 3.03 of the rules, the home plate umpire must be immediately advised that a double switch is being made. In fact, a manager heading to the mound with the intent of replacing his pitcher as part of a double switch should first go to the home plate umpire, advise him of his intention, and then go to the mound to make the change. If not, the new pitcher automatically bats in the same slot as his predecessor, and the same goes for any other substitution being made.
It can sometimes be complicated to keep track of the new batting order once a double switch has been made, particularly if it happened as part of multiple simultaneous substitutions. A poorly executed double switch is a common cause of batting out of turn. The move is becoming rarer these days as relief pitchers rarely stay in the game for multiple innings, and the lack of substitute players on the bench, in the era of 7 or 8 men bullpens, limit managers' options for making substitutions.