A bit of sweetness combined with a savory main meat element and probably some spices is a standard combination in many cuisines. Having many contrasting flavor elements in one dish can be like a painting with many colors: Not the only way to do it, but pleasant, if done right.
A British Christmas gammon may be studded with cloves and get a honey-mustard glaze. The Chinese pork belly gets a sticky sauce with soy sauce, honey, sugar and spices. The French Canard à l'Orange adds sweet and fruity flavors to the duck..... You can probably eat your way around the world and find similar patterns. Even the American diner breakfast with pancakes, maple syrup and bacon uses these elements.
Your ham in coke is a simple way of doing something along that line: you have lots of sugar, a touch of acidity and a few “herbal” notes from the coke. So sorry, no, the coke is not a “magic ingredient”. From a cooking perspective, using the coke vs. another type of braising liquid or glaze is a bit like using “cream of... soup” in a casserole vs. making a separate sauce. Neither is per se better, it depends on the desired result and possibly circumstances.