When the basketball court was originally designed in 1936, the area now referred to as the key was much more narrow. The thin rectangular shape with a semi-circle at the top looked like a typical keyhole at the time, thus giving the area its nickname.
The top of the key refers to the area at the top of the free throw circle on either side of the court. It is often where the point guard will begin the offense's attack or pull up for a quick jump shot.
The key is a special location on the court, as there is a rule in the sport that applies only to that area.
There's a limited amount of time players can spend in the key. An offensive player can only spend three seconds at a time within the key, with or without the ball, before they must get out of it, or the referee will blow the whistle and the ball will be given to the other team. This can prevent a team from keeping players on one side of the court to catch passes and make easy baskets, since they will need to keep moving.
A defender can also not be inside of the key for more than 3 seconds at a time, unless they are directly guarding an offensive player.