The pancreas produces insulin, a hormone that controls the amount of glucose in the blood. In Diabetes type 2 the body develops resistance to the effects of insulin, so there is not enough insulin to meet the body's needs.
The sugar instead of moving into your cells where it's needed for energy, it builds up in the bloodstream.
The exact reason for the development of resistance to insulin is yet unknown.
Many medical, lifestyle, work and food factors play a role in development of diabetes.