Bitcoin mining is probably the most misunderstood parts of Bitcoin. Mining does 2 things, it records the transactions in a database and it protects the network from counterfeiters.
The database of Bitcoin transactions is called the “Blockchain.” It is the database of all Bitcoin transactions and all account balances. Since there are is no central authority like a bank all the users share the Blockchain via peer-to-peer connections. On average a new block is created every 10 minutes and that records the Bitcoin transactions. Mining records these transactions in “blocks.”
See the article: What Problem is Being Solved by Bitcoin Miners?
The second part of mining is stopping counterfeiting which is called a “double spend” in Bitcoin. It is like an electronic ticket to a concert. An electronic ticket can be copied and sold many times. To prevent this miners must do “work” before their block can be accepted into the Bitcoin system. A cryptographic calculation is done over and over until an acceptable answer is found. It is like printing lottery tickets. If someone wants to fool the system and tries to put fake transactions in a block then they will need more computing power than all the honest miners put together. This is called the 51% attack.
For more information see: Bitcoin Mining: What’s it all About?