At regular intervals, the Bitcoin program kicks out mathematical puzzles. There is no pattern to solving the puzzles. So the computers used by bitcoin miners generate an onslaught of potential answers, also random. On average, a puzzle is solved every 10 minutes but sometimes it can take more or less time depending on lucky guesses by the mining computers.
When a puzzle is solved, a predetermined amount of bitcoins is released to the miner whose computers solved the problem. Most miners pool their resources to have better odds of collecting bitcoins, and they divide the bounty accordingly.
At today's rate, 25 bitcoins are created every time a puzzle is solved, about every 10 minutes. At the next level of the program, that output will be cut in half to 12.5 bitcoins every 10 minutes. And then it will be halved again, per the specs of the program, until 2140, when 21 million bitcoins will have been created.
Since Bitcoin's inception in 2009, about 12.11 million bitcoins have been mined.
-- Monica Gokey