In biology, everything has a history. Creationists love to try to calculate the probability of a new gene spontaneously coming into existence, but that's not how genes are born. New genes most often come from other genes: one gene gets duplicated by a freak accident (like the accidental duplication of a chunk of chromosome, a whole chromosome, or even an entire genome), so that you suddenly have a cell with two working copies of the same gene. As time goes on (that is, time on an evolutionary scale), those two duplicate genes start to divide up the work that was originally done by just one gene. One copy might end up specializing in one particular task, picking up mutations along the way that gradually transform this copy into an independent gene in its own right, with its own specialized function. From one gene, you get two, each with a distinct role in the cell.
It sounds like a nice evolutionary story, but do scientists have any real examples of duplicate genes evolving new functions?