Mining is a guessing game. Bitcoin double-hashes a block header with SHA-256 and only accepts the block if the hash comes out below a target, so miners grind the nonce until they get lucky. Stacked up and linked by hash, those blocks become a chain you can't quietly rewrite.
Each extra zero makes blocks ~16× rarer. Bitcoin's real target needs ~19 leading zeros: around 10²⁴ hashes per block at today's difficulty.
Each block stores the hash of the one before it. Edit any block's data: its hash changes, so the next block's “prev” no longer matches and every block downstream turns red. Re-mine them left to right to heal the chain.
Finding a nonce takes millions of tries; verifying one takes a single hash. That asymmetry is the whole security model: cheap to police, expensive to cheat.
Change old data and you must re-mine that block and every block after it, faster than the rest of the network extends the honest chain. Practically: impossible.
Nothing trusts a timestamp. The chain's order is enforced purely by which blocks point to which, and by how much computation is piled on top.