How can transaction fees be explained in a simple way? I am reading the book Mastering Bitcoins 2nd Edition by O'Reilly, and it says:

Alice buys a coffee from Bob's Cafe for $1.50, or 0.015 Bitcoin

So Alice pays 0.015 Bitcoin, and Bob gets 0.015 Bitcoin, but there is a transaction fee, paid to the miner.
There are some questions:

Does Alice pay more or does Bob get less?  (the fee has to come from somebody)
The way to calculate the fee seems to be a whole essay. Typically, what kind of percentage can the fee be, if it is a $1.5 coffee, or if somebody sends another person US$1 million dollar worth of Bitcoin, or if it is exchanging Bitcoin for US$1 million? But one person mentioned that it is voluntary (even the link above said the spender &quot;may&quot; include a fee, suggesting they can choose not to), but who would want to pay a fee if they don't have to? I can understand if they send over US$1 million and the fee is $13, then they probably don't mind and &quot;want&quot; to include a fee.
The miner gets the fee -- is that the miner who originally did the mining of the coin, or is it that somehow, the fee (or transaction) gets encrypted and a new miner has to mine it.  It is described as: all the miners compete to find the next new Bitcoin, but there is also Proof of Work (to get a fraction of Bitcoin), but there is no mentioning of the miner getting a transaction fee. How does it factor into the flow or procedure?
Does Alice pay more or does Bob get less? (the fee has to come from somebody)

Alice pays more.
It works like this: Alice submits a transaction with inputs adding up to, for example, 0.016 BTC. This transaction  includes outputs totaling 0.015 BTC to Bob. The difference, in this example 0.001 BTC, would be the transaction fee in this case.

The way to calculate the fee

The fee of Bitcoin transactions is calculated on the size of the transaction, not the value being transacted. For each byte of your transaction, you are bidding a certain number of satoshi, known as the &quot;fee rate&quot; -- so for example, if you chose a 100 sat/byte fee rate, and your transaction is 600 bytes, then your transaction fee would be 600*100=60000 sat (0.0006 BTC).
You are bidding for space in a block. Because only a certain amount of transactions can go into each block, most miners will select the transactions with the highest satoshi per byte fee rate, because it is more profitable for them to collect these fees.
Technically you could choose a 0 sat/byte fee rate, making your transaction free of fees, but nowadays miners will probably not include your transaction in a block because they'd be losing money (and nodes will probably not propagate it), so your transaction will never confirm. However, it's still a valid transaction, and indeed, earlier in Bitcoin's history when transaction volume was much lower and block space wasn't so competitive, most transactions included 0 fees.

I can understand if they send over US$1 million and the fee is $13, then they probably don't mind and &quot;want&quot; to include a fee.

The price of the transaction is completely irrelevant to the fees. Since it's by the size of your transaction... if your $10 USD transaction is very complicated and results in a large transaction, you may end up paying a hilariously large fee to have it confirmed. By contrast, if your $1M transaction is very simple and the transaction is very small, then the fees for that transaction will be low, despite it being a high value transaction.

The miner gets the fee -- is that the miner who originally did the mining of the coin, or is it that somehow, the fee (or transaction) gets encrypted and a new miner has to mine it. It is described as: all the miners compete to find the next new Bitcoin, but there is also Proof of Work (to get a fraction of Bitcoin), but there is no mentioning of the miner getting a transaction fee. How does it factor into the flow or procedure?

The miner who mines the block that first includes your transaction gets your transaction fee. Let's say your transaction was included in block #123. The miner who mined block #123 receives your transaction fee.