most of the answers here were correct, but since nobody gave a complete explanation, i'll try to explain this in a newbie-friendly, but complete (albeit, simplified) , way
When you send bitcoins from address A to address B, you generate a transaction, in which you basically say: "i'm the owner of address A, and i want to use incoming transaction (input) W and incoming transaction X (input) to create output Y to address B and output Z to a change address of me (address C). The difference between the inputs and the outputs is the fee i leave for the miner". You sign this piece of text using your private key, and you send the text to the network.
In the network, it only exists in the memory pool of the nodes... When they reboot, or when they clean up their memory, your transaction is gone... Byebye
In order to actually remember your transaction, it has to be included in the decentral database. This database exists out of datablocks of 1Mb. A miner collects transactions, does a lot of complex calculations with them and the header of the previous datablock, and if he wins the complex calculation, he gets to mine the next block containing all kinds of transactions he had in his memory. At this moment the miner gets the block reward (currently 12.5
BTC) plus the sum of the fees most transactions included.
Now, at this moment, there usually are a lot more transactions in the memory of the nodes than will fit in a 1 Mb block. So when the miner selects 1 Mb of transactions, it is wise of him to select the transactions that have the most fee per byte of transaction data (since he'll only be able to fit 1 Mb of transactions in his block). So, the transactions with the highest fee per byte usually gets included in the block.
To come back to your question: once the blocks have halved a couple more times, the block reward gets close to 0... At this point, the fees should be enough reward for the miner to keep on mining. If the fees are insufficient, some miners will stop mining, leaving more blocks to be found for the leftover miners, increasing their earning potential...
So, when the block reward is ~0, i either expect the mining equipment to be so efficient, and the
BTC price so high, it is still profitable for the miners to keep mining for the fees, or i expect to see a drastic drop in hashrate (and difficulty), so the couple hardcore miners can make a profit from the fees because they mine so many blocks...