The NBA Draft Lottery is the league's way of ensuring that the team that finishes a given season with the worst overall record isn't guaranteed to receive the first overall pick. The system isn't perfect; it doesn't prevent teams from tanking to secure the highest possible odds of winning the lottery, and the picking of ping pong balls out of a machine isn't exaclty riveting to watch.
The actual drawing takes place off the air before the televised event, but the drama during the broadcast and the reactions of team representatives can still produce some extremely entertaining results.