In basketball, coaches will often bench players who are in early foul trouble because they want to avoid losing that player if they foul out. The more fouls they get, the closer they are to being disqualified from the game for fouling other players so much.
In the NBA, each player is allowed to commit six personal fouls in a game before they "foul out" and are disqualified from playing in that game. They will be sent off the court after the sixth foul is committed.
In college basketball, each player is allowed to commit five personal fouls before they are disqualified from playing for the rest of that game. They will be ejected from the game once they commit the fifth foul.
By benching players who have accumulated several fouls early, the coach can ensure that they can still play toward the end of the game. If left in, the players would probably accumulate more fouls and be ejected before the game ended. Coaches will save their better players on the bench once they have committed a few fouls to ensure they are still able to play in the end when they are more important. Losing a major player in the middle of a game can greatly affect the success of a team.
Coaches can also bench players to let them rest during a game. If they notice that a player is getting tired and slowing down, and if they have a player to replace them on the court, a coach can bench a player for a short time to allow them to catch their breath and drink some water. They can also use this as an opportunity to talk to the player and give them advice for when they go back onto the court.