The Bayer matrix is the spatial arrangement of the red, green and blue pixels on a color sensor. A single pixel cannot capture all wavelengths, only the primary colors. Therefore, there are three different types of pixels, called RGB, on a sensor. Without offsetting, this would lead to a loss of 2/3 of the liquidation.
A color sensor of 30 MP, for example, delivers 30 MP color information. This is achieved in that the blue pixel fetches the missing color information red and green from the nearest pixel and uses this information to calculate the real color. This creates 30 MP color information, each from the three values of the basic colors. This process is called demosaicing and the offsetting is the know-how of the camera manufacturer. However, since many different sensors have to be calculated, the Bayer standard has been agreed upon. Here 50% green, 25% blue and 25% red pixels are used.
This division of colors corresponds roughly to that in nature. There are also different methods, for example Sony uses two different shades of green.