One way to answer Achashverosh’s sudden seeming change of heart is the fact that he regularly changes his mind about things since he lacks any true convictions. As the saying goes regarding this fickle king: he listened to a friend to kill his wife, and then he listened to his wife to kill a friend.
However, R’ Yehonason Eibshutz explains that Achashverosh’s negative feelings towards Jews were caused by a vision that he had earlier in his life that a Jew would take his throne. Once he found out (Esther 7:4) that his wife was a Jewess, his child through her, although a Jew maternally, could take the throne after Achashverosh passes with no harm coming to him. Indeed, according to the Talmud (Megillah 11b) Esther’s son, Darius II ruled after him.