William MacGregor is a noble character. He is a man who holds a large grudge against the protagonist.
Throughout Card Shark[]
He and Erdnase work for other nobility behind Louis XV's back.
At some point later on, while having Erdnase and the protagonist a card game, if all of the aces are dealt to Erdnase in the final game, King Louis XV theorises MacGregor might have been working with a cabal under his brother's orders to poison Sophie, as his brother saw her as a threat.
He becomes so enraged with the protagonist cheating while playing against King Louis XV, that he basically admits to having poisoned Sophie during his outburst.
He claimed that Erdnase murdered Sophie, when in fact he poisoned the tea that was only supposed to make her fall asleep. He framed Erdnase for Sophie's murder, only to have Erdnase return and have him out himself in front of the King twenty years later.
He surrenders to the protagonist after their duel, fatally wounding him immediately thereafter. What he essentially does after stabbing the protagonist after their fake duel. He allows the hero to be saved by Julie, who helps set-up his revenge against the Comte - which also allows the protagonist to get to Versailles and inadvertently causes MacGregor to have his rant when he complains the Comte is cheating against Louis XV. All because he was scared the protagonist would return and try and claim the throne.
The reason he's after the protagonist is to stop him from potentially claiming the throne as the King's long-lost son, and to avoid the news that the King had a son by a secret wife from leaking to the public.