Alkaloids are natural products, they usually occur in plants, and they contain one or more N-atoms typically in a heterocycle. Alkaloids often have pronounced pharmaceutical effects. The alkaloids are produced by way of isolation from the plants in which they occur naturally.
Nicotine occurs in tobacco leaves and cocaine is extracted from coca plants.
Morphine is obtained from the opium juice of some poppy plants. Heroin is acetylated morphine. These alkaloids are difficult to make from scratch. Total synthesis of these molecules are known but they are too complicted and too expensive and synthesis cannot compete with the isolation of the natural products. And now there is methamphetamine as the big drug of the '90s.