The term 'spacing' in basketball refers to how far away members of the offense are from one another on the court. Teams that are proficient with regards to spacing manage to occupy virtually every part of the floor while the offense is attacking the defense's half of the court.
Good spacing allows offensive players that are not currently handling the ball to make a series of cuts towards open spots on the court. These "off ball movements" are used to gain separation from defenders and generate open shot attempts. Once the ball handler identifies an open teammate, a pass can be completed, often leading to a made basket for the offense.
Coaches will often seek to maximize open space by drawing up plays that exploit the immense amount of ground the defense must cover in order to stop the opposition from scoring. The most common type of play call is the "back cut," in which a player standing on the side opposite of the ball handler makes a quick move towards the basket. More often than not, the defense will have naturally shifted towards the location of the ball, opening the door for easy entry passes into the painted area just underneath the basket. If the defense is anticipating a pass and over commits to one side of the court, ball handlers can quickly dribble past their respective defenders.
Teams that fail to maintain proper spacing are unlikely to achieve success on offense in the long run. When too many players are in close proximity to one another, it becomes easier for defenders to guard their assignments. For example, if an off-ball player is standing just a few feet away from the ball handler, the off-ball player's defender can essentially guard both members of the offense without having to move very far.
Poor spacing leaves the offense susceptible to double teams (two defenders collapsing on the player with the ball) and easily interceptable passes. These types of situations often cause offensive players to panic and make ill-advised decisions, allowing defenders to steal the ball and take possession away from the team operating on offense.