I always found this to be such an odd law, especially given it is so new, only 10 years I think. But at the same time Turkey is incredibly nationalistic so it's also not completely unexpected that they have a law protecting the state and certain offices from insult, despite how illogical and detrimental it is.
Remind me of Lèse-majesté which still exists in a number of countries, including a few European ones, but I always think of Thailand simply because they revere King Bhumibol so much, but their enforcement of that law pales in comparison to Turkey and Erdogan.