This is something most (if not all) historians are trained on. This is what we refer to when we speak of cultural bias. We may view certain methods as barbaric, backwards, uncivilized etc etc when as you have noted, "they are a product of their times." However, it may not necessarily have been the case for a number of reasons. I will attempt to give a few examples;
An example of this is The Bloody Code which is essentially a systems of laws adopted by the British in the mid-to-late 17th Century which made over 200 crimes punishable by death. As many countries are now "progressing" towards abolishing the death penalty, we view this as a barbaric practice. However many of these laws dealt with wealth and land; two of the largest issues facing the British Empire. In their eyes, stolen property and wealth could potentially compound and topple the Empire; to steal your neighbors silver was an assault on the Empire. Thus if crime ran rampant, they faced the collapse of their entire way of life and indeed the world order. Now we know this to by exaggerated and even hyperbole but whether or not it is true does not make it no less true for THEM. Two of the last laws punishable by death under this act was High Treason and engaging in counterfeit. The second may be surprising and rather a harsh measure but again, counterfeit undermines the economy which I believe most of us can agree is tenuous. Leave four or five counterfeiters to do their work, you can potentially crumble that countries economy. That is still the case today and counterfeiters face serious jail time.
Now you were speaking of rulers being a product of their time or viewed akin to Hitler. I will use this as a comparison to Julius Caesar. Here we have a man who ended the Roman Republic, conquered Gaul and essentially committed a cultural if not ethnic genocide (for lack of a better term, I use genocide; but it should not be applicable in this sense for genocide has much different connotations today than it did then). Caesar had hundreds of thousands of innocents killed based off his own pride, he killed his own countrymen, he was not a supporter of the traditional Rome, he corrupted and crippled the senate, he flooded the ruling class with sympathizers, he fostered civil war in foreign countries, he was arrogant, prideful and his power revolved on the cult of the personality.
Enter Hitler. He was a man who ended the established German Government and took his minority party forcing out the majority, he conquered most of Europe committing a cultural and ethnic genocide. He had hundreds of thousands of innocents killed based off his own pride, he killed his own countrymen, he was not a supporter of the traditional German Empire, he corrupted and crippled the government, he flooded the upper class with sympathizers, he fostered civil war in foreign countries, he was arrogant, prideful and his power revolved on the cult of the personality.
Notice any similarities? Certainly, they are quite similar in personality, methodology etc but we see them each as products of their own time. Julius Caesar headed an Empire that needed to expand to survive and thus many brutal methods needed to be employed. The methods that he employed were horrible; akin to what methods Hitler used to progress his ideologies and the Third Reich. Historians have a very difficult time removing their own bias from their argument and this is especially true with figures like Hitler who existed not so long ago and had lasting impacts down to individual. Myself for example, three of my great uncles who lived in the Netherlands during the war were drafted into the German army. Two joined the Luftwaffe and all three were killed during the Siege of Stalingrad. Other family members were taken to Concentration Camps never to be heard of again. Much of my family today does not exist because of what Hitler did. However Historians as a profession owe it to the material to analyze it for what it is. When we begin to put our own judgement and values upon the material we read over is the same moment we lose sight of the real picture as seen within that time. This does not make the individual any less horrible than they are/were, but take a look at the larger picture, what their motivations were and tell the story for what it is.