Anytime the ball is dead, or not in play, the manager or coach may substitute players. In major league baseball, once a player has played and then been substituted for, that player may not return to the game. This rule often does not apply in youth leagues where players are moved around during the game to allow for fair playing time.
Pinch Runner
Sometimes the manager may want to substitute for the base runner. The new runner is called a pinch runner and is generally used near the end of a close game when the team desperately needs a run and the current base runner is slow. The coach will substitute for a faster runner to increase the chance of them scoring. The pinch runner then takes the place of the substituted player in the batting order.
In youth leagues, catchers are often substituted for when they are base runners, especially if there are two outs. This is to allow for more time for them to get their gear on and save time between innings. This does not really count as a substitution and is sometimes called a "courtesy runner".
Pinch Hitter
Often times in games, the coach will decide to substitute for the hitter. The new hitter is called a pinch hitter. Coaches do this to get a better hitter into the game for a certain situation. Often they do this when the pitcher is up and they planned on taking the pitcher out of the game anyway.
A lot of strategy can go into using a pinch hitter. Generally left handed hitters hit better against right handed pitchers and vise versa. Sometimes a manager will put in a pinch hitter to take advantage of this, but then the other team's manager will counter by changing out pitchers.
Relievers
The pitcher who starts the game is called the starting pitcher. All other pitchers who come into the game after the start are called relievers. Some pitchers are almost always used for the last inning of a game. They are sometimes called closers.
Injury
Players may need to be substituted for injury. Generally the substitute pitchers are allowed additional time to warm up during this instance.
The Designated Hitter (DH)
The designated hitter, or DH, is not really a substitute, but a position on the team. In some baseball leagues, like the American League in the Majors, the pitcher does not have to bat. Instead there is a position on the team called the designated hitter. This player does not play a position on the field, but hits instead of the pitcher in the batting order.