Why are green screens green?

It's partly about how human colour vision works, partly about avoiding colours you want to keep, such as those of the actors.

Colour cameras record concentrations of red, green and blue light to mimic human colour vision. Before digital techniques, blue screens were preferred because, of the three primary colours, that's the one rarest in human skintones.

When digital cameras were invented, they were given greater sensitivity to green light to mimic a bias in human vision. Green screen doesn't require as much illumination of the screen as blue screen does, which prevents the risk of chroma spill onto the foreground subject's edge, which can cause a special effects failure called a chroma halo.

In the pre-digital era, when the foreground-background distinction had to be much larger than is required today (because of the complicated optical process involved in achieving chroma key), it was almost impossible to get away with any colour beyond blue. Nowadays both colours are very common, with green almost the new default; but, unlike the blue-only era of the past, typically both colours are now on standby.

I may misunderstand the question, but the method of selecting the background based on colour you are asking for is called chroma keying.

In digital post-processing, all pixels which are sufficiently green are considered background and hence treated as transparent. What is "green" is configurable, often in HSV colorspace.

J.G.'s answer elaborates why green usually works best. Blue screens are common, too.

From Wikipedia:

Chroma key compositing, or chroma keying, is a visual effects/post-production technique for compositing (layering) two images or video streams together based on color hues (chroma range)... to remove a background from the subject of a photo or video... A color range in the foreground footage is made transparent, allowing separately filmed background footage or a static image to be inserted into the scene. [...] This technique is also referred to as color keying, colour-separation overlay (CSO; primarily by the BBC), or by various terms for specific color-related variants such as green screen, and blue screen – chroma keying can be done with backgrounds of any color that are uniform and distinct, but green and blue backgrounds are more commonly used because they differ most distinctly in hue from most human skin colors. No part of the subject being filmed or photographed may duplicate the color used as the backing.