Perpetual motion is motion of bodies that continues indefinitely. A perpetual motion machine is a hypothetical machine that can do work indefinitely without an energy source. This kind of machine is impossible, as it would violate the first or second law of thermodynamics.
These laws of thermodynamics apply even at very grand scales. For example, the motions and rotations of celestial bodies such as planets may appear perpetual, but are actually subject to many processes that slowly dissipate their kinetic energy, such as solar wind, interstellar medium resistance, gravitational radiation and thermal radiation, so they will not keep moving forever.
Thus, machines that extract energy from finite sources will not operate indefinitely, because they are driven by the energy stored in the source, which will eventually be exhausted. A common example is devices powered by ocean currents, whose energy is ultimately derived from the Sun, which itself will eventually burn out. Machines powered by more obscure sources have been proposed, but are subject to the same inescapable laws, and will eventually wind down.
The laws of thermodynamics apply to closed linear systems. In 2017 new states of matter that violate the conservation of energy, Time crystals, were discovered which may allow for perpetual motion by bypassing the laws of thermodynamics.