I assume you're asking how the "mining" works, and that's actually pretty easy to explain.
Each bitcoin block is generated with a SHA256 hash of the block's header. Presumably, the header information is not guessable, otherwise it would be pointless.
The SHA256 hash becomes the "target." In order to successfully mine the block, you must produce a hash with a value lower than the target. The lower the target, the harder it is to mine the block. Since SHA256 hashes (as far as I know) do not leak any information about the plaintext, the hashes are attempted essentially at random. Successfully mining a block is essentially like winning the lottery because there is no known way to make educated guesses about what text might produce a hash below the target's value.
Once an acceptable hash has been generated by a miner, it is submitted to the network with a proof of work that permits the rest of the network to essentially check the solution. At that point, the block is considered completed, the transactions are processed, and the successful miner is awarded the transaction fees plus 20 new BTC.
I don't think the rainbow table comparison is apt because you're not attempting to produce hash collisions, only find hashes below a set value. Finding a collision is exponentially more difficult, by design.