The person has some problem in life e.g. death of some dear one, problem in marriage etc. It's a multi factorial illness, that is to say that a variety of factors and their combination is responsible. Important contribution is of certain brain chemicals. Their decreased presence is considered to be a factor. One such chemical is Serotonin.
Inheritance is another importance contributing factor.
Sometimes some close relative in family suffers from this illness. Personality of the person might be very perfectionist. Upbringing from childhood can have an important role. Yes, Very much. There are medicines available, which are very effective.