WARNING: SPOILERS FOR MANGA CHAPTER 414/ANIME EPISODE 308.
Aizen Sosuke did not trust anyone, least of all Ichimaru Gin.
The former Captain of the Fifth Division had known for a long time that his second-in-command was planning on killing him. The only question was how and when.
Truth be told, Gin was a gamble. Aizen did not like to rely on chance, trusting his own intelligence to make plans and backup plans so that every conceivable outcome would be a victory. But with Ichimaru Gin, whose only predictable factor was that the boy was planning to kill him, Aizen did not have a choice but to gamble.
It was one thing to know that there was a snake in the grass that was waiting to kill you. It was quite another to not know when aforementioned serpent was going to bite him. Aizen feared for the longest time was that Gin would make the attempt at the worst possible time. Telling the fox about Kyoka Suigetsu's only flaw was both a method of trying to control when the assassination attempt would occur, and a ruse to fool Gin into thinking that Aizen trusted him. Although he always kept his guard up, the Captain of the Fifth Division knew that if anyone could sneak through a crack in his defenses and kill him, it would be Ichimaru Gin. Even after obtaining the Hogyoku, dramatically increasing his already formidable strength, Aizen was still afraid that the snake would attack before he was far enough along in the bond with the powerful orb to survive and increase his power.
When Aizen felt the fang of Shinso pierce his chest, he experienced a mix of rage, terror, and relief.
Rage, because there was a miniscule part of him that hoped that perhaps Gin would stay by his side the entire way. After all, the amusing boy had been with him the longest, and had been the most useful subordinate he ever had. Even though he knew the betrayal was coming, it still stung just a little.
Terror, because even though he had taken into account the Hogyoku and the need for fear in order to evolve, Aizen was afraid that Gin had struck at the perfect moment: when he was off-guard, when he least expected the attack to come, and worst of all, not yet fully bonded with the Hogyoku.
And of course, relief in the knowledge that Gin had played his part in Aizen's plan to become a god.
Aizen Sosuke was not a gambler, knowing that it was more practical to plan events out beforehand and manipulate them to his advantage. But in this one instance, in the unpredictable factor known as Ichimaru Gin, Aizen had to rely on random chance. And he won.
Author's Note: I always wondered why Gin had not struck earlier, when Aizen would not have had the protection of the Hogyoku. Then I remembered: killing Aizen was not Gin's sole objective. His second goal was to retrieve the Hogyoku and return the piece of soul that had been stolen from Matsumoto over a hundred years earlier. Gin's plan to kill Aizen was never intended to be a suicide mission; if it had, our favorite fox would have probably killed him in the Sereitei, long before Aizen betrayed the Gotei 13.
Gin knew he was looking for a particular window of opportunity. One, he had to be touching Kyoka Suigetsu's blade before an illusion had been cast. Two, he had to strike when Aizen was least expecting a betrayal from him. Three, Gin had to be in a position to successfully retrieve the Hogyoku. Four, he had to be in a situation where he could survive the assassination and theft long enough to get to Matsumoto.
Gin was scary-smart, almost as smart as Aizen. Therefore, there is a very good chance that if Gin did not see an opportunity to strike successfully before, then no such opportunity existed.
