When a sender creates a transaction, they explicitly define which pieces of bitcoin they spend. We call such pieces of bitcoin Unspent Transaction Outputs (UTXO) and you can think of the UTXO set as the distributed ledger of Bitcoin balances. The state of UTXO is ternary: they either don't exist yet, are available for spending, or have been spent. You can't deduct from a UTXO, they must be spent completely in one transaction.
Spenders explicitly pick the transaction inputs by referencing the UTXO via its unique outpoint
txid:vout which is derived from the transaction that created the to-be-spent UTXO and its position in the output list.
After declaring the UTXO getting spent, the spender has assignable balance to the sum of the inputs' total value. The spender will explicitly assign the value of the consumed inputs to new outputs. Any funds not assigned are considered transaction fees and will be collectable by the miner that includes the transaction in a block.
This means the total of assigned funds is less or equal than the value of the spent UTXOs, and the remainder is the transaction fee. The following hold true for non-coinbase transactions:
Σ(outputs) ≤ Σ(inputs)
transaction fees = Σ(inputs) - Σ(outputs)
So, only the inputs and outputs on transactions are explicitly defined. The transaction fee is implicitly defined by the inputs and output.
It follows that a simple transaction sending to a single recipient will usually have two outputs:
- a recipient output to conduct the payment
- a change output to return the remaining funds from the inputs to the sender
I grabbed a random transaction from blockchair.com to visualize:
If Alice's wallet had not created the change output to itself, Alice would have paid 11,044.… BTC in additional fees. ;)
Note, that I'm simply guessing that the 610 BTC is the recipient output due to the round number, I'm not intimately familiar with this transaction.