Vitamin deficiency, particularly in vitamins D, B6, and C, can contribute to poor sleep quality and insomnia due to their roles in regulating neurotransmitters and hormones involved in the sleep-wake cycle.