This answer is copied from my answer on a duplicate question of this one: https://bitcoin.stackexchange.com/a/10351/1307
You should start here: http://www.youtube.com/watch?v=GmOzih6I1zs
As the video mentions, mining is needed to ensure fairness and for keeping th network stable, safe and secure.
Now, let's see what that means. But first a very brief explanation of the principle of mining.
The Bitcoin network consists of nodes that all store a database with all transactions, called the block chain. This database consists of a long chain of blocks, each holding one or more transactions. What miners basically do is bundling all unconfirmed transaction into a block. The form of the block must satisfy certain conditions before the block is considered valid. This condition is called proof of work and is not trivial to understand. When a miner finds a block that is valid, it can send its block to the network and others will verify it. When it is indeed valid, all clients will add it to their block chain. Every time a miner finds a valid block, it has the right to assign a certain amount of bitcoins to himself, called the block reward. They also get all transaction fees of all transactions included in his block. This way, new bitcoins are added to the network and it can be ensured that transactions can be confirmed.
Since Bitcoin is peer-to-peer and there is no central authority to control it, every one can send any kind of transaction to the network, whether or not it is valid. You could simply send a transaction that sends someone else's coins to yourself.
Luckily no one in the network will accept your transaction. When you want to spend bitcoins from a certain address, you will need to sign the transaction with the private key of that address. Other clients in the network can verify that you own that private key because they have the public key. This method is based on public-key cryptography.
So when miners try to bundle unconfirmed transactions into a block, they first need to confirm every transaction to make sure that all transactions in its block are valid. When they are not, other clients will not accept the block they mined when they sends it to the network.
This way, miners ensure that people can only spend bitcoins they own.
This is the least difficult one to understand. The Bitcoin protocol sets the difficulty of the mining problem so that averagely every 10 minutes a new block can be found by some miner. This way, a transaction takes 10 minutes to be confirmed on average.
However, after a transaction has been included in a block, it still is not irreversible. This is not easy to understand, but when a miners try to mine a new block, they include in that block the number and the ID of the previous one. So let's say someone mined block 100, which follows number 99. It can happen that someone else didn't notice that someone found a valid block to follow on 99 and makes a valid number 100 itself as well, let's call it 100'. In this case, most clients will only accept the first block they received. But it can happen that another miner received 100' first and will find a block following on 100' and not on 100. Then we have following situation:
98 - 99 - 100
\ _ 100' - 101'
When clients notice such a situation, they will always choose the longest existing chain (that only consists of block they think are valid). This means that block 100 will be discarded and that 100' and 101' or now the two last block of the main chain. This means that a transaction that was confirmed by block 100 is now possibly no longer confirmed. Luckily, the miners that found block 100' or 101' probably also knew of the transaction and most probably they also included it in one of those blocks. But it can happen that they did not and so a transaction can be undone.
For this reason, most clients and merchants require a transaction to be confirmed by at least 6 blocks. This means it must be included in a block that has at least 5 blocks after it.
The fact that a transaction will be able to be considered confirmed after averagely 1 hour, makes it a stable situation. It happens rarely that transactions confirmed for more than 1 hour will ever be reversed again.
Safety and security
The previous part about stability already included some security aspects of mining. It is clear that miners make the Bitcoin block chain trustworthy. When a transaction is included in a block and 5 or more other blocks have passed, you can be sure it is irreversible and safe to accept it as a payment.
It is also clear that the safety and security of Bitcoin as a payment system is in the hands of the miners and that every time one of them solves a block, he has the power to decide what transactions he accepted to the block chain.
Mostly, all miners are fair and they will include as much valid transactions as possible. Whenever a miner is not fair and it selectively excludes some transactions, some other miner will likely include it in the next block.
There is however one flaw. When a miner has more computation power than all other miners combined, it can always create new blocks at a faster rate than the others. This gives him much power over the block chain, and that is to be avoided at all cost. This flaw is named a 51% attack. This answer sums up the consequences of what could happen if someone would have 51% of the network computation power.
But this is a security flaw, what has this to do with why miners should mine? Well, as more people mine, the total computation power rises and it will be much much harder for someone to perform such a 51% attack. Currently, to own hardware capable of performing such an attack would be so enormously expensive that it is economically unfeasible to do, if not completely impossible. So, every miner tht contributes his power to the network ensures that only fair miners will find blocks and that the network will be safe for people to trust upon.