Melanocytes are specialized cells located in the basal layer of the epidermis. They are responsible for the production of melanin, the pigment that gives skin, hair, and eyes their color. Melanocytes synthesize melanin through a process called melanogenesis and transfer it to surrounding keratinocytes, which helps in protecting the skin from ultraviolet (UV) radiation.