Royal jelly is a special kind of food the bees feed to larvae to produce a queen. The bees produce a new queen if the old one is not laying enough eggs or if the hive is to crowded. It is the workers who decide when they need a new queen, and they just feed one or more young larvae with royal jelly to produce a queen instead of a worker. A couple of days before the new queen emerges from its cell the old queen leaves with about half the bees to form a new colony. If there are more then one queen cell the first queen to emerge will (normally) kille the others in their cell. This is the bees way of reproducing as you can view the hive (family) as one organism.
Actualy, all larvae are fed with royal jelly, including workers. The difference is that queen is fed just with royal jelly, but workers just for short time.