The Opium Wars that occurred in China were the direct result of western nations mainly England and their illegal sale of opium to citizens of China. England and it's people were addicted to tea specifically tea sold in China. In their addiction they went as far as to make it their national drink. Thus most trade was concerned with the procurement of tea leaves. But China in it's ideals of Social Darwinism and eastern supremacy only partook in the action of selective borrowing. Blinded by their isolationist views and partial racism they banned all trade with England concerning China's importation except for raw and refined ores like silver and gold. They also disliked exporting any precious resources except for those they had in excess like tea leaves.
All these tariffs and restrictions prompted European powers to find a cash crop that they had in excess which they knew China didn't have. So like the tea that England couldn't produce and got addicted to, China's people soon became addicted to the opium they couldn't make. This addiction though soon came to surpass England's own problems. Seeing this advantage England took it and continued to export the smokeable version of opium. Left unchecked it consumed China's economy by sucking out the previously procured silver and destroying its policies of banning European made goods. This poor judgement was not because of the China didn't want to stop the opium trade it was mostly because of the sly merchants and the addictive traits of opium that made slaves out of those who encountered it. In the battle to stop the opium trade China was to a degree overzealous. This is displayed by the fact China either deported merchants or killed anyone selling opium on sight and in any case the completely seized and destroyed any merchandise. The Leaders of China did not enforce this however seeing as the trade didn't come in periodic explorer type missions trying to make contact whilst piercing the almost mythical veil of Asia. It was just basic trade to its citizens which made it undetectable except for warehouses and periodic ship searches. So for the street and administrative enforcement the Emperor of China appointed one Lin Tse-Hsua an imperial commissioner. This time he tried to stop it at it's source by sending a letter to the Queen of England unfortunately it was apprehended by "Bourgeoisie" and Parliament officials and never reached her hands. The British finally had had it with the unceasing anti-drug stance of China. The impending confrontation was a result of the differences in trade and yet again like so many times before England seeing itself as the victim and supreme ruler of everything. The straw that broke the camel's back was when a group of merchants and their ship were turned around.
The merchants subsequently complained to Great Britain making England consider the end to be a forceful meeting. After the commissioner told the British that they would never voluntarily halt their practice. The refusal finally lead to the naval and military involvement of Britain or the first Opium War. In the conflict many ports were destroyed and to stop the destruction China surrendered signing the Treaty of Nanjing opening four more ports to European trade and jilting the trade custom duties to favor Britain subsequently this lead to making the Chinese second class citizens in their own country by granting more privileges to Europeans. China brought the second opium war upon themselves by again boarding a English ship and messing with it. Yet again China lost because of England's superior navy and guns. Thus after a nudge in the form of burning down the Imperial Summer Palace, 11 more ports were opened, religions mingled, and drugs were legalized when they finally signed the Treaty of Tianjin.