Queen supersedure
When an older queen starts to lay fewer eggs the existing bees might decide she need to be replaced, when this happens they chose an ordinary worker bee egg and build a peanut shaped cell around it. Once the egg hatches the bees feed the new queen larvae only Royal Jelly which is a special mixture that basically allows the usually non sexually mature worker bees sex organs to become mature in order that she once mated with several drone bees she can lay eggs.
This special mixture is fed only Royal Jelly until about 6 days old at which stage the worker bees encase the larvae in a peanut shaped cell (known as a Queen cell or Swarm cell). The larve will transform into a queen Bee (same sort of thing how a caterpillar transforms into a butterfly).
When the new queen is about to emerge from her queen cell the other worker bees will sting the existing queen to death as if left alive she would fight the newly emerged queen to the death.