The way Bitcoin works is that instead of having one central authority who secures and controls the money supply (like most governments do for their national currencies), this work is spread out across the network. Most of the heavy lifting for Bitcoin is done by "miners".
Miners collect the transactions on the network (like "Alice pays Karim 10 bitcoins" and "Liam pays Sofia 8.3 bitcoins") into large bundles called blocks. These blocks are strung together into one continuous, authoritative record called the blockchain, which doesn't permit any conflicting transactions. This is necessary because without it people would be able to sign the same bitcoins over to two different recipients, like writing cheques for more money than you have in your account. The blockchain lets you know for sure exactly which transactions count and can be trusted (so no bad cheques).
The way Bitcoin makes sure there is only one blockchain is by making blocks hard to produce. So instead of just being able to make blocks at will, miners have to compute a cryptographic hash of the block that meets certain criteria. Bitcoiners refer to this process as "hashing." The only way to find a cryptographic hash that's "good enough to count" is to try computing a bunch of them until you are lucky and find one that works. This is the "lottery" that David Schwartz refers to, because miners who successfully create a block are rewarded some bitcoin according to a pre-set schedule. The difficulty of the criteria for the hash is continually adjusted based on how frequently blocks are appearing, so more competition equals more work needed to find a block. A modern GPU can try hundreds of millions of hashes per second, so to be competitive in this race to find hashes miners need specialised hardware, otherwise, they will spend more on electricity than they make in the "lottery".
In addition to the hash criteria, a block needs to contain only valid, non-conflicting transactions. So, the other main task for miners is to carefully validate all the transactions that go into their blocks, otherwise, they won't get any reward for their work!
Because of all this work, when a Bitcoin client signs onto the network it can trust the blockchain that was most difficult to produce (since this is evidently the one that was being worked on by most miners). If there was a "fake" blockchain competing with the real ones (say, where someone pretends that they didn't actually give Sofia those 8.4 bitcoins and they still have them), the fraudster would have to do as much work as the whole rest of the network to make their blockchain look as trustworthy. So, essentially, the intense work that goes into finding blocks through hashing secures the network against fraud. There is also, of course, the code that figures out how to choose between conflicting transactions; and what to do if two people find valid blocks at the same time.
Finally, you're probably wondering why it is called 'mining.' In the original analogy, people who performed this essential work were compared to gold miners digging gold out of the ground so that everyone could use it. But in reality, Bitcoin "miners" are just running computer programs on very specialized hardware that automates the process of securing the network. To sum up, this software:
1. Collects transactions from the network
2. Validates them, and doesn't allow conflicting ones
3. Puts them into large bundles called blocks
4. Computes cryptographic hashes over and over until it finds one "good enough to count"
5. Then submits the block to the network, adding it to the blockchain and earning a reward in return.
6. That's mining in a nutshell!