[Short version] Loki is inside The Hulk. Heimdall helped Loki escape, and Thanos knows. Loki will be hunted down anyway, so the escape is momentarily & wasted (he could have used it on somebody else), and Heimdall will be executed for this.
[arguments]
Banner, who has years of experience controlling Hulk, is in control of them all, but once Hulk manifests Loki would take over (forever). To prevent this, Hulk refuses to come out AT ALL. Hence so little screen time for the big green guy.
Loki is also feeding Banner information about Thanos, which is why Banner knows so much in the movie about things he should not.
Heimdall knows Loki is in Banner, that is why he transported Hulk to earth so quickly (Thanos would torture innocent hero Hulk to inflict pain on Loki). Thanos knows where Loki is, and that Heimdall knows, which is why he says it was a mistake (Hulk + Loki will be hunted down and tortured anyway). Thanos kills Heimdall there and then for his role in Loki's escape (Thor is left alive, since Thor did not directly break his rules).
Thanos merely kills Loki (even tough he should be tortured for his Tesseract failure and endless betrayal), because it is a mere shell of the real Loki. This is also why Thanos so explicitly says: "No resurrection for you this time". He is aware Loki's essence/soul is alive, but he cannot resurrect without a body.
Hulk vs Thanos actually being Huloki vs Thanos (with Hulk + Loki fighting for control) allows for a much better Hulk/Huloki vs Thanos fight in Avengers 4.
[Me attempting to write version]
Loki, a cowardly schemer by nature, was desperately searching for a way out. He was stuck on a spaceship, with Thanos, and he knew that torture was waiting for him (1). That is when it came to him, he would transfer himself into the Hulk and take over. It was a clever move befitting the God of mischief.
For who had a better chance against Thanos than Huloki? He had seen the Hulk and his stupid brother fight, and even Thor's newfound Lightning Power only gave the Hulk pause (2). All he had to do was take control of the giant green oaf's brain, similarly to what Scarlet Witch had done before (3). If Huloki could not defeat Thanos with brute force, he could try a ploy like he had done with Algrim (4). If the worst came to pass, and Huloki was defeated, he would hide safely in insect Banner. Thanos does not crush insects without a reason (5), so he would be safe inside Banner while his physical body inhabited by his illusion would be tortured.
Unfortunately, as with all of Loki's plans, it would not work out. Upon transferring, the Hulk began fighting Loki for control, and Thanos quickly defeated the absent-minded Huloki. Worse for Loki, Thanos was not so easily fooled and was aware of what the trickster had done.
But then something happened he did not expect (or did he?). The all-seeing Heimdall, having trained himself for years to see trough Loki's tricks (6), not only knew that Loki was in the Hulk, but had also seen that Thanos was aware of it as well. Loki quickly realized that Heimdall would not allow Huloki to be tortured: the Hulk had just saved Thor and ultimately the people of Asgard, and it would be unthinkable for such a hero to be tortured because of the things Loki had done. Thus summoning the last of his powers, Heimdall transferred Huloki away to earth.
It was a little later that Loki learned what had happened next. Thanos could not allow what Heimdall had done to merely pass, and gave him a clean death. The only solace that could be found was that Heimdall knew that what he had done was not for nothing; Thanos had said that Heimdall had made a mistake, thus making it clear that Thanos was indeed aware of Loki inhabiting the Hulk. Thanos, not caring to torture the fake Loki, had merely killed Loki's physical body, preventing his immediate resurrection.
The story of Loki ends (for now) with Loki as a mere helpless parasite. The Hulk refuses itself to manifest, knowing that Loki would take control. For now Loki had to content himself with feeding Banner information about Thanos. If only Hulk would stop raging in his ear about how he made him loose a fight for the first time ever...
(1) Avengers - “If you fail, if the Tesseract is kept from us, there will be no realm no barren moon, no crevice where we cannot find you. You think you know pain? He will make you long for something as sweet as pain.”
(2) Thor 3.
(3) Avengers 2.
(4) Thor 2.
(5) Avenger 3.
(6) Thor - "Never has an enemy escaped my watch until this day. I want to know how it happened."