Black lips, nose, and gums help protect dogs’ fur-less areas from excessive sun exposure damage. Those were selected for by evolutionary pressure.
The black color comes from melanin pigmentation, which also protects cells from damage caused by sun radiation.
It is also genetic—if two dog parents have black lips, you can be very confident that their puppies will have those black lips too.
Some dog breeds with black lips include Labrador Retrievers, German Shepherds, and Boxers.
In sunny climates, evolution has favored dogs with more black pigmentation.
Those dogs with black features would be less affected by sun radiation due to the melanin. This meant fewer fatal skin conditions, a longer life, and more black-lipped puppies to pass on those black lips to the next generation.
It’s worth noting that not all dogs have black lips. Since sun exposure isn’t as damaging in less sunny climates, dog breeds living there did not have to go through the same evolutionary pressure.
If your dog has naturally lighter lips, gums, or nose that recently become darker, or vise versa, it may be a cause of concern. While it is not a disease, it may be a sign of one.
In that case, I recommend taking your dog to the vet to rule out health problems.