Occasionally there is a problem with the biological machinery. The DNA is built wrong, it's damaged in such a way that it cannot carry out its task. The change is permanent and if it happens in the sex cells, the eggs and sperm, it will be passed onto the next generation.
A mutation changes a gene's instructions for making a protein, causing the protein to malfunction or stop working. If this protein has a vital role to play in the body the consequences could be severe. Many genetic disorders and conditions are caused by mutations. It is important to remember that it's not a gene that causes a disease but a deleterious change to that gene. For example Cystic fibrosis is not caused by the CFTR gene, it is caused by mutations to that gene.
Mutations are not always dangerous, some will have no effect at all. They can happen at any time without you ever knowing about it. You can read more about the causes of mutations by clicking on this link http://www.brighthub.com/science/genetics/articles/6105.aspx