As @BobBrown said in comments, we need to ask what problem the passport stamps are supposed to be solving. Turns out it is a security problem, but not in the way you are thinking (I think). Let's say I'm a Canadian visiting the UK. In addition to providing a record for the UK gov - which surely they're also recording in a database - it acts like a receipt for me in case, at some point during my visit, I'm asked to prove that I entered the UK legally. For most airline travelers, the stamp is the only legally-binding entrance paperwork that you're given. The stamp is placed in your passport to tie the stamp to your name and for your own convenience, but I believe many countries will give you the stamp on a slip of paper if you're concerned about the privacy issue of putting it in your passport.
You might think "there should be a central database that tracks entries and exits". Problem: 1) this information is for domestic tracking only, countries will object to letting other countries see their border records, and 2) I - the Canadian citizen - am the person who needs the proof. If it's stored in a UK federal database, why should I trust that it won't be tampered with, or modified to frame me?
"Ok, ePassports now contain smart chips, your entry / exit info should be stored encrypted on the chip". Problems: 1) you - the random citizen - don't have the tech to verify that the entry info placed on your chip is accurate (whereas with a stamp you can look at it when it's handed back to you). And 2) given that every country has different policies about passport stamps (like Israel who gives a separate "Landing Slip" rather than putting it on the passport), and given how much trouble we're having getting the current specs for ePassport adopted by all countries, good luck with that.