The healthy human pancreas is an awesome machine, secreting the exact right amount of insulin into the bloodstream to allow the glucose from your food to enter your cells and be used for energy. When you eat, your pancreas secretes more insulin. When you exercise, it dials back the insulin. And if you don't eat for a long time, it makes another hormone called glucagon that tells your liver to put more sugar into your bloodstream. If you don't have diabetes, that system keeps your blood sugar within a very tight range.
In people with Type 1 diabetes and some with longstanding Type 2 diabetes, that system is broken and the insulin has to be replaced manually, by shots or a pump.
Insulin pumps, which have been available for decades, deliver insulin via a small catheter inserted under the skin throughout the day, but the wearer has to tell it how much and when. Getting it right all the time can be extremely difficult, because pump wearers have to check their blood sugar, make educated guesses about the amount of carbohydrates they're eating and how much they exercise, and set the pump accordingly.
Essentially, it's trial and error. And even if you get an on-target blood sugar value once, the next day might turn out differently because you exercise or eat more or less or get sick or stressed or, as one patient quipped, "the moon was full."