Dear Brother,
In order to understand why he was executed, one needs to have an insight into the Islamic History. As far as my memory serves me, the reason lies in the animosity between His uncle and Father-in-law Hujjaj bin Yusaf and the later Caliph Sulayman (who had Muhammad Bin Qasim executed).
Hujjaj was very close to Khalifa Walid (during whose reign Muhammad Bin Qasim attacked) and was trusted by him. Probably Hujjaj had sided Walid, against Sulayman, and therefore Sulayman always had a grudge against Hujjaj (if i may recall correctly).
However when both Hujjaj and Khalifa Walid died, Sulayman called Muhammad Bin Qasim back to Baghdad and had him executed.
The death of Muhammad Bin Qasim sounds like a folk legend or a tale out of the 1001 Arabian Nights. There are several versions to it and they all are equally disputable.
One such version says, that Muhammad Bin Qasim had captured two daughters of Raja Dahir whom he sent as gifts to Sulayman (as was customary in those times). When the girls reached Sulayman, they told him that Muhammad Bin Qasim had de-flowered them before sending them to Sulayman. This was an obvious insult to the Khalifa, whom promptly called Muhammad Bin Qasim back to Baghdad and had him executed. The legend goes on to say that once Muhammad Bin Qasim was dead, the girl admitted to the fact that they had fabricated the story to avenge their father's death. Upon hearing this Sulayman was so furious that he had them tied to the tails of horses and they were dragged on the ground till the time they both were dead.
Personally speaking, i believe that Sulayman did it more out of Political necessity and his foolishness than anything quoted above. Out of three famous Muslim generals, Tariq Bin Ziyad (called back by Al-Walid and badly treated by Sulayman, whom died in the streets of Damascus begging for food near his end), Muhammad Bin Qasim (killed while in prison) and Qutaiba(he captured Kashghar ), all of them were killed brutally.
So more or less Sulayman was against all the generals and their associates who had been handpicked by his brother Al Walid