The king has always been ruthless, I mean, he singlehandedly brought down the 5 noble families quite early into his reign. Like most rulers, he hella paranoid. So if such a person were to ever trust/ love anyone, but was later betrayed, he'd definitely be much more beastly. He was never rational, amicable etc. He appeared that way to the MC, but to the others, he was ruthless and coldblooded. A tyrant.
Chapter 25 has a rough summary of his accomplishments before he'd met our MC. To have achieved all of that before 25, it's indicative that a lot of his enemies blood was shed. As for the reason he was kind to the MC, it's cuz he knew that the MC was being sabotaged when he saw the blueprints for the palace but the MC didn't cower or make excuses. He confidently spoke of his vision and I think that truly appealed to the emperor. As for why he was cruel to our MC, he truly believed that there was a love affair.....regardless, that emperor is and was always a tyrant who only knew to plunder to get what he wanted. He has a special place in hell.
******@++++ is correct. The bad blood between the 5 noble families & the emperor existed from the very beginning. That's why Heun chose to stay silent, for fear he would make things worse by telling the truth. The livelihood of entire clan was at stake. While the emperor felt betrayed, after all, this is a guy he knew came from the enemy's clan, but he chose to trust him, & ended up liking him. But Heun returned the favor by either "plotting treason with the clan" or "using spies to set up trysts at the palace". Understandably, he was enraged. His pride would not have allowed that. And so he forced Heun into his harem, & when Heun would not be subdued, he tortured him, crushed his foot, etc. (yes, being an emperor apparently makes him unaware of how to properly love another person). At the end, he resorted to using the aphrodisiac, which mellowed Heun, much to his delight. And for that, he paid the ultimate price, losing the one he truly loved.
Oh, I didn't think he believed the part about treason. Since his followers were harping about it, he bought it up.....but, what enraged him was the potential affair. He'd been trying to court him (or what passed as courting for an emperor) but was always rejected. Now he realizes it's cuz there may've been s/o else in the MC's heart...etc.
Either way it's the same, the circumstances forced his hand, because in this kind of royal setting (where the ruler's position isn't set in stone, and thus he absolutely can't afford to blindly trust anybody) it doesn't matter what the ruler actually thinks about a situation, but what it looks like to all other people... I mean, in Asian kingdoms it's always painted like this in fiction: even the king's own blood relatives, and even his own children, can and may be (constantly) trying to find a way to steal the throne from him, let alne his subjects. So, once his subjects start thinking he can be "fooled", it can quickly turn into a *game over*, for a king.
...Moreover, if it's a brand new kingdom, recently created out of the conquest and forced annexation of several smaller kingdoms, where he can't claim rulership from "tradition", and thus his own position is much less "secure".

doesn't add up. nothing organic about that transition. a rational, amicable, dreamer and ruler sees a hickey on someone he has a lowkey crush on and finds out there are spies in his court (and knows in his gut that it wasnt his crushes doing) so he just mentally flops the switch into being a living raping nightmare? I know these things arent rational but as a monarch he's always had an enabling environment to be a monster. A hickey and lords being lords just seems super insignificant.