Before the shot clock was introduced in 1954, teams could run out the clock if they had possession, leading to endless passing and no change of possession. This made the game terrible to watch because the pace of play was so slow, so the league introduced the shot clock.
A very strong defense can deny a shot within the 24 seconds clock and force a violation resulting in a turnover. They can also force a low percentage shot towards the end of the shot clock by playing hard on the ball defense and not letting the offense have any room.
The offense can use the shot clock to their advantage to make sure they get the last shot of the game, also called a two-for-one. For example, if there is 35 seconds left in a game, a team will shoot the ball early in the shot clock so the other team will get the ball with more than 24 seconds left in the game. This ensures that the original team will get the ball back for a final shot because once 24 seconds is up, the other team will have either shot the ball or committed a 24 second violation.
Recently, the rules for 24 second violations have changed a little bit. College basketball's shot clock went from 35 seconds to 30 seconds. The NBA changed the rule about shot clock resets. This is when a team gets an offensive rebound after a shot, the shot clock is reset. Now, instead of resetting to 24, the shot clock resets to 14. This was an attempt to make the pace of play faster.
30* (mens), 20 (womens)
*IMPORTANT: Although the shot clock reset time for Men's NCAA basketball is 30 seconds, if the defense commits a foul and the shot clock is below 20 seconds, then the shot clock is reset to 20 seconds.