Because cryptocurrencies are decentralized systems running on peer-to-peer networks, and there is no central server farm, its necessary to build into the system an incentive to get people to run the software that powers the system on their personal hardware. Mining also answers the problem of how to distribute the currency, by forcing individuals to work for it.
Miners must pay non-cryptocurrency for the computer hardware they use and the electricity that hardware uses. Miners with slow hardware will have trouble competing with those using large, custom-built farms of mining hardware. In the early stages of mining when a cryptocurrency is new, mining can be an easy way to earn. However, as mining become progressively more competitive, unsuccessful miners will probably spend more on electricity than they will earn in free currency.
Once a miner successfully decrypts a transaction hash, it is added to the block. Blocks are added to the blockchain roughly every ten minutes, at which point the miner earns a set amount of Bitcoin. As you can see in this example from blockexplorer.com, there are about 2000 transactions per block.
There is no guarantee that a transaction will make it into a block any time soon. In theory, it could sit in the pending pool indefinitely. This is where fees come into play.
The first blocks that were mined produced a reward of 50 BTC per block. However, the system is designed to cut the number in half every 210,000 blocks. For a while, miners earned 25 BTC per block, but when it reached block 420,000 in 2016, it halved again, at which point the reward for mining became 12.5 BTC per block. The reward for mining will remain 12.5 BTC per block until it reaches block 630,000, when it will halve again to 6.25 BTC.