Bitcoin is a payment system that has a number of characteristics that make it superior for some applications, e.g. international money transfer, online commerce, and peer-to-peer money transmissions.
Mining serves the purpose to slowly spread sufficient liquidity to the community, in order for it to be usable. Also, mining serves the stability of the Bitcoin network by validating transactions, and protecting against fraud. People giving their electricity and hardware are reimbursed by the miner's reward, creating an incentive to do what is good for the network. In exchange every user gets to use the Bitcoin network.
The mining reward is given out in a kind of lottery, but since it is being given out so often and through the miners forming mining pools, the reward is actually spread pretty evenly to all miners.