Mining is essential for the existence of bitcoin as it makes transactions possible. If you send bitcoin to a friend he won't have the bitcoin in his wallet instantly, but instead there will be shown the amount that is being sent with the notice 'not confirmed'.
The transaction first has to be verified by the miners in order to be confirmed and credited to your friends wallet. Miners use special hardware (for example the 'Antminer s9') that are often placed in giant empty halls in countries where the electricity costs are very low. Miners are rewarded with new bitcoin as well as the transaction fees.
If you want deeper insight on how bitcoin mining and the blockchain work these articles have helped me a lot:
But you don't need expensive hardware in order to mine bitcoin. You can do it from home by using the cryptotab browser. It is a webbrowser that uses google chrome and mines bitcoin while you are surfing on the internet.
Of course the amount of bitcoin you earn won't be high but I mean you use the internet anyway, so why not earn some bitcoin while doing so.
If you don't want to use your own computer for mining but also don't want to buy expensive mining hardware you could take a look at cloud mining. Basically the concept behind cloud mining is paying someone so that they let you use their mining power.
But I don't have any experience regarding cloud mining, so I don't feel like I can share links with you here. It would be wrong since I wouldn't know if they are actually real or just scams.
Maybe I will try cloud mining in the future and update this site with more information.