Neurotransmitters are chemicals that are used by neurons in the brain to communicate with each other. Instead of using a neurotransmitter only once, neurons have a method of recycling them to save on the resources used. There are chemicals located on the surface of all neurons that allow them to recollect the neurotransmitters floating outside and bring them into the neuron again to be used later. The presence of these neurotransmitters within the neurons is responsible for the feeling of pleasure and pain.
Psychoactive drugs stop the neurotransmitters from being taken in by the neurons again once they have served their purpose. Cocaine is known to act on three neurotransmitters: dopamine, serotonin, and norepinephrine. Chemicals in cocaine block the proteins located on the neurons from taking in these neurotransmitters again after they have served their purpose.
This results in the feeling of immense happiness or euphoria which is the primary reason why cocaine is consumed.