The Ambush on Knowhere was an attempt by Thanos to steal the Reality Stone and manipulate Gamora into revealing the location of the Soul Stone.
In the aftermath of the Second Dark Elf Conflict, the Aether, which actually was the Reality Stone in a liquid state, was given to the Collector on Knowhere by the Warriors Three, as the Asgardians, who already possessed the Tesseract, considered that they could not store two Infinity Stones on Asgard.
However, the Titan Thanos soon sought to acquire all the Infinity Stones into his Infinity Gauntlet so he could fulfil his plan of wiping out half of all life in the universe. Along with the Black Order, Thanos began a quest for the Infinity Stones, stealing the Power Stone from Xandar and the Space Stone from the Asgardians when he attacked their spaceship, leaving Thor to die. Thanos then instructed his children to go on Earth to secure both the Time Stone and the Mind Stone while he would go to Knowhere to find the Reality Stone.
However, Thor managed to survive Thanos' attack and the destruction of the Statesman, and was rescued by the Guardians of the Galaxy, who answered the Statesman's distress call. Thor informed them of Thanos's plans, deducing that Thanos was headed to Knowhere to retrieve the Reality Stone.
While Thor, Rocket and Groot left for Nidavellir to forge a weapon capable of stopping Thanos, Star-Lord, Drax the Destroyer, Gamora and Mantis decided to track Thanos to Knowhere in an attempt to find and stop him.
During the journey, Gamora, who secretly knew the location of the Soul Stone, asked Star-Lord to kill her should she be captured by Thanos to prevent the knowledge she carried from falling into his hands.