Purpose of Transaction Fees
Transaction fees have two purposes.
The first purpose is to reward miners for their work and incentivize them to include transactions in their blocks. Without transaction fees, a miner would be better off creating empty blocks. Empty blocks are faster to create and get broadcasted faster in the network due to their smaller size. Both facts give selfish miners an advantage over miners that include transactions.
The miner who creates a block receives the fees of the transaction he included.
The second purpose is to avoid spam. If transactions would be for free, attackers could create billions of transactions without any high cost. Blocks would get cloaked, and the network would render a poor user experience due to long waiting times until a “good” transaction is included in a block. With transaction fees, spammers face high costs for creating an increased number of transactions.
Different blockchains have different transaction fee schemes. Some blockchains even burn a share or all of the fees instead of distributing them to the miners.
In Bitcoin, the miner receives 100% of the fees.