Gene duplications are common and happen by a variety of mechanisms including those mentioned by Sahar Qazi above. They can also occur by horizontal transfer and other mechanisms. In almost all cases, the original gene remains functional, and in many cases both are functional and essentially identical with identical function at first. Having two copies of a gene allows one of the two gene copies to drift to a new function or for one to become nonfunctional without detriment to the organism.
Sahar Qazi above seems to be implying that duplication does not often result in gain of new functions, but this is not correct. The vertebrate alpha and beta globin genes are just one example, and this duplication is not new, it occurred a very long time ago in vertebrate evolution.