America did not like the Taliban prior to 9-11, but considered them to be no threat to the USA. 9-11 changed the way we think. First, some background on Islamic extremism. There are many verses in the Qu'ran (e.g. Al Baqarah 2:190-194) that some Muslims interpret as commanding Muslims to kill unbelievers everywhere, all the time, and other Muslims interpret as commanding them to kill unbelievers when fighting in a holy war or when the unbelievers are threatening or oppressing you. There are similar books in the Old Testament (e.g. Leviticus, as bloody-minded as any interpretation of the Qu'ran), but there are not large numbers of people organized to follow these strictures and kill. Most if not all Muslim nations devote some resources to groups with these beliefs, but generally speaking this is considered just one of those things that one sovereign nation does which annoys another sovereign nation; part of life. Generally speaking, the mosques and organizations receiving this aid maintain at least a polite fiction of separation between the part that advocates for Muslims and/or provides charity for Muslims, and the part that chops off heads and blows up buses.
When the Taliban took over Afghanistan - easily the most warlike nation on Earth - that somewhat changed the equation. For the first time in modern history a nation openly backed a terrorist organization (al-Qa'ida or "the Base") dedicated to killing and driving out from Islamic lands all non-believers, toppling all non-believer governments, wiping out all other religions but Islam, and establishing Islamic theocracies in all countries. (It's important at this point to remember that all religions want to maintain purity and to be the One Religion, the difference being in the methods. Jehovah's Witnesses do not come to your door to convert you or kill you. Jews don't murder their daughters if they get raped. And of course, the vast majority of Muslims don't do these things either - but large numbers do.)
The reason this is key is because for the first time a terrorist organization could openly raise money, openly have offices and training grounds, with government backing and even government funding. A problem, but still not worth going to war. Then al-Qa'ida attacked the USA and killed almost 3,000 of us. Now it's a problem worth going to war.
At this point this easiest solution would be to use nukes. Wipe every city in Afghanistan off the face of the Earth, turn the country's cities into glazed glass. No more Afghanistan, no more safe haven for al-Qa'ida. Of course, contrary to what you seem to think the USA is not equivalent to al-Qa'ida, so that was never an option. That leaves limited war or simply rolling over and taking it. The problem with the second option - what America had been doing since Islamic terrorism began - is that Islamic extremists despise weakness. One Islamic terrorist organization killing 3,000 Americans and getting away with it inspires other Islamic terrorist organizations to try to kill as many or more Americans; America had become a paper tiger. Remember that the ultimate goal of Islamic terrorist organizations is to destroy all democracies and all religions but Islam, and to kill or enslave all non-Muslims.
If we use war but not nukes, then we have a problem. As I said, Afghanistan is easily the most warlike nation on Earth - they would have thrown us out. We would have killed ten of them for every one of us they killed, but we would have tired of it first, just as in Viet Nam. So our problem is to eliminate the Taliban and with it al-Qa'ida's safe base of operations, but without alienating the world any more than we have to. Luckily there were multiple factions fighting for control of Afghanistan - there are always multiple factions fighting for control of Afghanistan when they aren't united in fighting invaders -and the largest of these factions was more friendly toward America than was the Taliban. (Still demanding government by Sharia, but willing to accept some Western influences such as schooling girls and not killing them to restore family honor if they have the poor judgment or just bad luck to become non-virgins.) So we made a deal to help them overthrow the Taliban. Ever heard the old saying "The enemy of my enemy is my friend"?
Now to Canada's role, which is two-fold. First, Canada is a NATO treaty member; it has protection but also obligations under that treaty, to come to the aid of any other member nation upon any armed attack in Europe or North America (Article 5. When our Marines were killed in Beirut, there was no treat obligation to come to our aid. There was a legal obligation in response to 9-11.) The USA has always carried the lion's share of NATO's military responsibility, but all NATO nations recognized that if NATO didn't respond with at least token armed forces, then the USA could reasonably be expected to pull out of NATO. Even tiny Luxembourg has a double handful of people.
The second role, which is really an extension of the first, is the UN mandate. Recognizing that it does no good to Western civilization to remove the Taliban from power only to have them return to power six months later, NATO went to the UN and received a mandate to send a NATO-led force (the International Security Assistance Force) to Afghanistan to provide additional protection to the fledgling Afghani government as it stands up an army and a police force. As Sun Tzu said, he who guards all, guards nothing. One way to offset this somewhat is to artificially increase your strength with outside forces. You still can't guard everything - but you can guard more. As Afghanistan's armed and police forces become more capable and Afghanistan moves from a society based on the power of individuals (warlords and clerics) to a society based on the power of the state, NATO and UN forces will gradually withdraw. Without this assistance, powerful Islamist forces such as Iran, Syria, the Pushtu regions of Pakistan, and elements of Saudi Arabia would pour fighters and materiel into the Taliban's efforts until the Afghani government fell and Taliban rule (with al-Qa'ida) was restored.
As to the morality of the effort in effort in Afghanistan, there are effects beyond the elimination of a safe haven for terrorists. Although women are still considered property (first of their parents, then of their husbands), they now have certain rights. Parents may send their daughters to school and even university; it's even encouraged. Religious police do not roam the streets beating women who wear eye shadow or ripping out fingernails with polish. Women are not legally required to be covered from head to toe in a burqa (an Afghanistan invention.) Women can work outside the home and even own property (within the constraints of Sharia.) Polygamy and bride price have been abolished, meaning a man cannot buy a young bride nor replace an aging wife without divorce and compensation. A girl who is raped cannot be legally murdered by her family to "restore the family honor." A girl cannot legally be sentenced to be gang-raped by the brothers of a woman her own brother slept with. None of these things were true under the Taliban. I suspect you would still find it a living hell - but it's a hell a few layers up from the hell of living under the Taliban.
If none of these things have value to you... Well, enjoy your life and hope that enough Canadians value these things to keep your freedom for you.