Pinball is an arcade game. Players use paddles or flippers to maneuver metal balls on a playing field inside the machine. The goal is usually to score points by hitting targets, bumpers, and other objects on the playing field. But you also have to avoid certain obstacles. The game ends when the player loses all balls. Usually after a certain number of balls have been played or a certain goal has been achieved.
As for legality, yes! Pinball machines are legal in most places in the world. However, there have been times throughout history when gambling or moral issues faced legal restrictions or were banned. For example, in the mid-20th century, some jurisdictions in the United States considered pinball machines a form of gambling. So they ban it or strictly regulate it. But these days, they are generally considered harmless entertainment. And it is widely popular in playgrounds, bars and private collections.