Mining is a little complicated to explain but essentially you have machines brute-forcing hashes (since they are one-way only) to receive a reward. This is PoW and the difficulty of doing so is dependent on the network and adjusts accordingly. The bitcoins that are sent to the miner that succeeds in hashing a value lower than the target (refer to the Bitcoin Dev. Guide) consist of the mining reward (right now at 12.5 BTC) and the transaction fees in their chosen block. This is why paying a higher fee/byte ratio will get your transaction confirmed faster since miners will want to earn the highest amount for their work.
Check out this link for more information, because it's a pretty interesting read: https://bitcoin.org/en/developer-guide#proof-of-work