Cannabinoids (such as CBD) influence a wide array of bodily functions. Endocannabinoids ('endo' meaning 'inside') are cannabinoids made naturally inside your body. These closely resemble the cannabinoids that occur in hemp (also known as phytocannabinoids).
Endocannabinoids are created locally and on-demand to target acute cellular issues (contrast this with hormones, for example, which are synthesized in a gland and then widely circulated throughout the body). Anandamide, the most notorious endocannabinoid, is responsible for regulating: 
- Reward pathways
- Motor functions
- Immune function
CBD interacts with cannabinoid receptors and enhances their activity - while at the same time boosting endocannabinoid levels.
For example, CBD inhibits FAAH (Fatty Acid Amide Hydrolase), an enzyme that breaks down anandamide. Essentially, CBD directly increases anandamide levels in the human body.
CBD (and other cannabinoids) aren't the exclusive ways to nourish the ECS, however. Essential fatty acids, cacao, herbs, spices, and teas either have building blocks of endocannabinoids or compounds that bind to our cannabinoid receptors and offer beneficial effects.
While the purpose of cannabinoids in plants remains unclear, the most popular hypothesis suggests they act to protect the plant from insects, bacteria, fungi, ultraviolet radiation, and drying.