The term was coined by Nick Szabo in the 1990s to describe:
a computerized transaction protocol that executes the terms of a contract. The general objectives are to satisfy common contractual conditions.
According to the Ethereum Foundation, a smart contract is a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. Smart contracts can define rules, like a regular contract, and automatically enforce them via the code. Smart contracts cannot be deleted by default, and interactions with them are irreversible.
In the Ethereum context then, a smart contract is neither particularly smart nor necessarily a legal contract and the progenitor of Ethereum, Vitalik Buterin, would rather on reflection have called them something like persistent scripts.