Cocaine has two effects on the body, mediated in different ways. This isn't an uncommon thing for a drug to do - most drugs have side effects. The first thing that cocaine does is induce local anaesthesia when it is injected into tissues (or dropped into the eye). It was a very handy drug around the turn of the 19th century for this effect as it allowed minor surgery without pain. The second thing that cocaine does is interfere with neurotransmission - the way that neurons talk to other neurons (or other cells, like muscles).
Nerve terminals release neurotransmitters to communicate with other cells. These generally small chemicals diffuse across to the target cell and bind to receptors to elicit a response. The fate of released neurotransmitters is either degradation by enzymes in the vicinity or re-uptake by the nerve terminal. Re-uptake requires a transporter in the nerve terminal, and it is some of these transporters that cocaine blocks.
Now, in the brain cocaine blocks dopamine and noradrenaline re-uptake, leaving more of these neurotransmitters free to bind with receptors, causing the euphoric effects that cocaine is rather famous for. The story in the rest of the body is rather simpler, and this is where the connection to asthma comes in.
There are nerves that release noradrenaline all over your body, and they affect various processes without you having to think about it (in fact, you have no direct control over these nerves at all). These nerves constitute the sympathetic nervous system, and two of the things that they cause when stimulated are vasoconstriction (decreased diameter of blood vessels) and increased activity by the heart. Users of cocaine will be familiar with the increase in heart rate (and force of contraction) and physicians regularly warn against the increase in blood pressure that cocaine produces via its twin effects on the heart and the blood vessels. But how would these effects be of any clinical use in the treatment of asthma?
The answer is a historically interesting one. Around the mid 1870's early attempts at bronchoscopy (looking inside the airways) revealed that during an asthma attack the lining of the airways (the mucosa) becomes red and swollen. It was (quite correctly) surmised that during an attack, blood flow to the mucosa increases, causing swelling that reduces the diameter of the airways and hence limits airflow. It didn't take to long for someone to reason that if you inhaled cocaine, it would constrict the blood vessels in the mucosa and reduce the swelling. It would have worked (but not as well as current treatments), and it had a brief life as an asthma treatment from about 1885 to 1900. Suffers would have found the relief produced by cocaine better than the mixed bag of very strange advice given by physicians at the time.
We don't use any drugs for asthma that work in a similar way today. We tend to use drugs that cause relaxation of the muscles around the airways, rather than constriction of the muscles surrounding the blood vessels in the mucosa. We do have cocaine-like drugs in modern use though, and they have their uses. But that's another post.