An NFT is a unique digital asset that is not directly replaceable with another digital asset (thus the name "non-fungible"). Many physical assets are also non-fungible. Real estate, for example, is non-fungible since each piece of property is unique from others.
A "fungible" token, by contrast, is one that is replaceable with another one identical to it. Ether is the fungible token that trades on the Ethereum network, meaning one Ether is identical to another. The same goes for Bitcoin. One Bitcoin can be exchanged for another Bitcoin because they have the same value. Physical currencies work this way, too. One physical dollar bill is the same as another dollar bill, and thus each are "fungible." But each NFT is unique; there isn't another one exactly like it out there, so they are non-fungible -- or unable to exactly replace another.
Code is written into this digital token and recorded using the blockchain network it's based on (again, usually on Ethereum) to prove a list of historical ownership and the current owner of a unique digital asset. An NFT can represent any digital creation -- art, music, videos, writing, etc.