Megillat Esther is fictional, or at least a heavily fictionalized version of true events. So I can treat the Megilla like any other piece of fiction, (albeit a sacred one in this case), when it comes to analyzing the characters and their motivations. What follows is simply my own personal interpretation of what might have been the motivation of one of the main characters of the Megilla. This has nothing to do with history.
Achashveirosh is most often seen as a bit of a bumbling fool. He is easily manipulated by his advisors, as is seen in his impetuous decision to banish Vashti, and in Haman's easily won decree to kill all the Jews.
He seems entirely oblivious when Haman comes to the royal chambers late at night. He already KNOWS that Haman plans to kill the Jews. He KNOWS Mordechai is a Jew. and yet, before Haman has a chance to speak, he cluelessly tells Haman to lead Mordechai around on a horse in honor! Is it any wonder that we see him as buffoonish character?
The best (read: most successful in maintaining power) kings in history are often the ones that can play to the masses, and though they have absolute power, still maintain a popular base with the people. But, being kings, they still use their dictatorial powers strategically, when they need to.
Let's look at Achashveirosh and reinterpret his actions assuming he was that kind of king.
The first incident is obvious. Vashti disobeyed him. He needed to show his empire that he could not be disobeyed. So he follows the advice to send her away and confiscate her estate for the next queen.
But that left a vacuum. Think of the role of the First Lady in America. She humanizes the President, and often helps with his popularity. Achashveirosh knows he needs a queen. So, again with advice of his counsel, he immediately launches a search for a new one. And not just from among the aristocracy, but among the population at large. Any supporters of Vashti would likely have been pacified by the excitement of the possibility that their daughters might become queen. The year-long search distracts and entertains the empire. And the search itself humanizes and makes the king seem more accessible to the people. He's looking for his queen. That's something that the people can find relateable.
But here things go slightly awry. Perhaps the king planned to pick a young woman from a prestigious family. But he was smitten with Esther. In this case, the story doesn't really differ from our traditional understanding. God's hand is hidden, but guides the king's heart towards Esther.
That's all preface. Then the action picks up pace. The Jews are pretty numerous in the kingdom. So are Haman's people, the Agagites, and his allies. These are two power bases, both potentially supportive of the king. Achashveirosh decides to promote Haman to be his second in command, an extremely powerful position. By doing so, he's also symbolically showing favor to the Agagites and their supporters. This is a clear move to show them that they are in his favor. And in return, Achashveirosh hopes for their support. There are no polls, but a partisan base doesn't hurt. Plus, they are well-off, and some "campaign contributions" to the royal coffers certainly won't hurt either.
Achashveirosh has made his choice between these two groups and makes it clear that everyone else knows it too. The Agagites are the winners, the Jews are the losers, and he hopes that the Jews will know their place and stay subservient.
Haman's thrilled, except for one thing. Mordechai doesn't seem to understand that the political sands have shifted. He's not acting subservient and doesn't seem to know his place. We know this part of the story. Haman devises his plan.
Achashveirosh grudgingly goes along with the plan. He was hoping the Jews would know their place, but since that's not happening, well, best to go along with Haman and eliminate them completely. He can't have a "third column" undermining his authority. Plus, Haman's "campaign contribution" is very appreciated.
Here's where the politics really start. One night, Achashveirosh can't sleep. He's tossing and turning. Perhaps he drank too much at Esther's banquet that day. But he's also preoccupied with the decree to kill the Jews. It's certainly not pangs of conscience. Like most rulers in the ancient world, Achashveirosh is pretty ruthless when he needs to be, and genocide doesn't really bother him.
But it's a shame to let a perfectly good power base go to waste. The Jews are smart, well connected, and, as he was just reminded by the story of how Mordechai foiled the plot against him, potentially loyal. If they could become part of king's power base too, he would truly be secure on his throne.
Then Haman shows up, and the king has a brainstorm. How to convince Haman that the king also favored the Jews? How to make a public display that the Jews and the Agagites could work together? The answer? Send Haman out leading Mordechai's honor guard! This would make it clear to Haman that he wants Jews and Agagites to work together and support the king together. It would also show the public that it was a new day.
Unfortunately, Haman's anger burns too bright. The king is a pragmatist, (albeit a ruthless one). Haman is not. He hates the Jews as deeply as any Anti-Semite in history. He's not willing to compromise.
The next day, at the second wine party, Esther reveals all. She's a Jewess. And Haman wants to destroy her people. Upon this revelation, Achashveirosh storms out to the garden to think. According to one midrash, he's already decided to kill Esther and side with Haman. But when he comes back in, the pragmatism leaves him when he sees Haman seemingly assaulting his woman on the bed. And like Helen of Troy earlier, or Ann Boleyn later, the fates of empires often rested on love of a woman. That's the turning point, and Achashveirosh the politician is replaced by Achashveirosh the jealous monarch. So Haman's fate is sealed.
But now the king as a problem. He was hoping to keep his monarchy shored up by the support of the powerful Agagites. Now he's had their leader executed, and they're sure to be very, very angry. So Achashveirosh does the only thing he can do. He pivots his favor towards the Jews, wholeheartedly. They're back in favor, and Mordechai is elevated to the top spot. He allows the Jews to defend themselves, and conveniently, this eliminates those now-furious Agagites.
וּמָרְדֳּכַי יָצָא מִלִּפְנֵי הַמֶּלֶךְ, בִּלְבוּשׁ מַלְכוּת תְּכֵלֶת וָחוּר, וַעֲטֶרֶת זָהָב גְּדוֹלָה, וְתַכְרִיךְ בּוּץ וְאַרְגָּמָן; וְהָעִיר שׁוּשָׁן, צָהֲלָה וְשָׂמֵחָה.
And the rest, as they say, is (apocryphal) history.