The greatest risk factors for type 2 diabetes are likely genetics and the metabolic syndrome (overweight/obesity and its associated comorbidities such as insulin resistance). Diet clearly has a major role in the latter, but the reason the role of sugar in the diet is still controversial is because a lot of the data comes from epidemiological (observational) studies. These studies are meant to identify correlations, but correlation is not necessarily causation, and it is also impossible to control for all potential confounding variables.
For example, some recent review articles:
One that refutes the role of sugar intake and diabetes risk - https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5436961/
A meta analysis showing a strong correlation - https://www.bmj.com/content/351/bmj.h3576
There is a pretty good review here that is very much worth reading if you are interested in the topic: https://link.springer.com/article/10.1007/s00394-016-1340-8
Basically the correlation appears strongest when high sugar intake is also contributing to excess overall calorie intake. This is not surprising. If you start drinking a 6 pack of soda daily in addition to your normal food intake, of course you're going to gain weight and your risk of diabetes development is going to increase significantly.
As noted in the article, keep in mind that while fructose is often scapegoated, the studies linking fructose intake and metabolic dysfunction is based on subjects/animals receiving a very significant portion of their daily calories from fructose, a dose that is larger than what most people consume on a daily basis. Now of course you don't want your diet to be high in simple sugars, but it's not helpful to demonize fructose exclusively, because if fructose was in absolute terms bad for you then you'd have to avoid fruits (after all fructose is "fruit sugar" and fruits also naturally contain sucrose, which is a disaccharide of glucose and fructose). Diets higher in fruits and vegetables have been inversely associated with diabetes risk (i.e. it decreases risk). For reference, a large apple only contains about 13 grams of fructose.
I just hope that people don't come away with the idea that moderate/high carbohydrate intake automatically leads to increased diabetes risk. After all, ALL carbohydrates are in fact sugars. And there are many large studies (observational) that show an inverse correlation between higher intake of whole grains and diabetes risk. Same thing for legumes.https://academic.oup.com/jn/article/142/7/1304/4743493https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3662533/https://academic.oup.com/ajcn/article/76/3/535/4677418
It's certain that the western diet pattern - high in refined grains, total sugar, total fat and types of fatty acids (high in arachadonic acid which promotes inflammation), and probably most importantly is by nature very calorie dense - increases risk of health problems. But if you like carbohydrates then eat nutritious sources of them without guilt.
TLDR: Genetics aside, excess overall calories is likely a greater culprit in diabetes risk than simply just high sugar intake.