Nature is an amazing force. The queen stores the sperm from the drones that she mates with in her body and can decide whether or not to fertilize each egg as she lays it based on the size of the cell in the comb (drone cells are bigger). Thus the drones carry only the queens genes but the workers carry both the queen's and those of the drone whose sperm were used.
The queen produces a substance which is passed from bee to bee round the colony which has several functions (almost certainly including a lot that we don't know about yet). One effect of it though is to suppress the ovaries of all the female workers. If the colony is without a queen for a period of time for some reason this substance is missing and you can find several of the workers will start laying. However because they have never mated all their eggs develop into drones. Since drones can't forage (or do much at all for themselves really) and their only role in life is to mate, this laying by the workers cannot prevent the decline of the colony but does give it a chance to pass on it's genetics.