if the code you need to run takes 20 seconds to execute, the visitor doesnt have to wait.
the code may not need to be run each time
you may not want the code to be run each time
also, say for example you "cron script" opened a file and did some reading and writing to it, modifying the file. what happens if its in the middle of modifying the file, and then another visitor requests a page, causing that half complete file to be opened again by the other script? expect bad things to happen. of course that can be prevented w/ file locking, but the problem is not specifically w/ working on files, i just used it as an example. undersired race conditions could happen w/ many diff operations.
w/ cron, the script gets run only when you want it to, on a set schedule.
also, if your website doesnt get any visitors for 3 days, cron will still do its job. but your php imitation cron job wont.