A matte painting is a special effects device.
If action requires a larger, more elaborate, or simply different environment than is available for filming, said environment could be produced by creating a painting of the scene with a certain area left blank. The blank area is later filled in with the actual filmed footage, creating the illusion that the action is taking place within the painted environment.
The procedure evolved to include the use of photographs and later digital artwork and CGI, not just traditional paintings. The term "matte painting" is still used. The artists are called digital matte painters.