Musk is used in basenotes and as a fixative, it extends the fragrance's life and can reinforce other ingredients. It is originally derived from glands of a male musk deer (the very word musk comes from the word for testicle in sanskrit). If you are interested in the details of musk extraction some googling will provide you with rather explicit descriptions. Today, however the musk used in fragrances is usually synthetic. The main reasons are said to be ethical and economical since the natural production has caused extensive killing of animals. It appears to me after some research though that in fact animals can rub the glands off by themselves so that they drop on the ground which means that musk should be able to be collected like this. But finding these glands would be very time-consuming of course.
Musk affects us hormonally and emotionally. It is associated with male sweat (more on this in a pheromone focused post coming up) and is said to affect a woman's menstrual cycle and her ability to become pregnant. Women perceive musk more during ovulation. It is however common that men and women cannot detect musk at all. In fact rather few people both sense and can define musk. Those who can, describe it as animalistic, earthy, primitive, clean etc.
Musk deer are originally from Tibet where musk is viewed as a remedy for a bit of everything. In China it has been used for medical treatments for at least 1500 years. It is a bit unclear when musk came to Europe but it is known that musk was part of a gift from the sultan Saladin to the Emperor of Eastern Rome in Constantinople. In the late 1200s musk appeared as a commodity in Venice. Musk was appreciated because of its healing effects but also a bit of a problem in terms of logistics because the smell affected other goods on the same ships, such as the valuable tea leaves. Even small amounts have strong effects on a fragrance formula.
Musk is a mythical and interesting ingredient in perfume. But not only in perfume... rather in scents in general. The powers will lead you into the area of pheromones if you start googling and then before you know you are in the most intricate olfactory-hormonal labyrinths.