Why Charles XII, or Karl XII is such a polarizing character in Swedish history today is mainly because of the fact that he has been used in various ideological context in the last 200 years.
I have to quote from memory since I'm on vacation and can't look in my books, but the main academic narrative is that the main flaws of Karl XII and his reign was that he focused solely on military, and while pursuing his campaigns with increasingly unrealistic wargoals and dismissed several opportunities to make peace, because he refused to accept losing the war. He basically bled the country dry on men and money, and neglected the home front while being a very capable field general. In his defence, he was attacked by a superior force, and did some interesting administrative reforms during his rule.
In the 19th century, his legacy as a "warrior king" and a pious protestant was used in the new nationalistic discourse, when the swedish state searched for national symbols of former glory. Swedish historiography emphazised the "Stormaktstiden", or freely translated as "the age of great power" in school curriculums up until the 1940's as an age of glory and something to be very proud of, and the kings of this age as great rulers.
This is the traditional narrative of Charles XII, rather uncritically viewed as a great warrior who defended Sweden against unfair odds and tragically killed before he could do greater things. Elderly people has been tought this in school, and residue of this perspective is still found in some books, magazines, museums, tv and school. This is also the narrative that modern ultranationalists adhere to, and uses in their political language. They probably got this from their roots in neonazism, as swedish nazis during the 1930's revered Charles XII.
The last 70 years of Swedish political history has been until the late 80's has been dominated by the left, and the academia in the 1960-1970's was heavily influenced by Marxist structuralism. This has led to a rather critical review of monarchial rule, and especially the absolutist kings(Charles XI, Charles XII, Gustaf III and Gustav IV). So the last generations of Swedes has gone through school with (in my opinion) a much more nuanced view of Charles XII. Today, the Swedish socialist left regularly use Charles XII as a example of tyrannical rule and harsh opression of the people. Today, neither the left or the liberal political organizations use the old kings as national symbols, though the nationalists and social conservatives do. I think this is the main reason why he's so polarizing, as he fits perfectly well in the narrative of many political factions, but in very different roles. One as a brave man and defender, the other as an incompetent tyrant. (To disclose my own standing, I do think he was a disaster for the country, but this has to be taken in context of the time, and how it's the office of absolute monarch is the main culprit in this. He wasn't spitefully harsh on the people, at least not compared to other monarchs of his time.)
Like I wrote earler, this is somewhat taken from memory. I can point to some good works on Swedish History, if you're Scandinavian you might be able to find them and read them:
Nordens historia. En europeisk region under 1200 år (2007), Gustafsson, Harald.
Makt och människor. Europeisk statsbildning från medeltiden till franska revolutionen (2010) - Gustafsson, Harald.
Orsakade Karl XII Stormaktstidens fall This is a online article from a popular history magazine though written by a academic Historian, you could try google translate this and get some kind overview of how the view of Charles XII reign has changed over time.
The Nation‐Building Process and the Development of the Secondary School System in Finland, Norway and Sweden at the End of the 19th Century Unfortunetly my university doesn't give me access to this article, but the by abstract it looks promising.