Totally anecdotal, but I went through a period of insomnia a few years age. It would take several hours to get to sleep. I realised that I had recently started taking vitamin D supplements just before bed and figured it might be connected.
Changed to take the supplements in the morning and the insomnia went away.
Apparently D3 inhibits production of melatonin. Can't remember where I read this so not a hugely useful comment but I promise I didn't just make it up! Anecodtally, I've also experienced similar issues taking 1000 IU D3 before bed and having trouble sleeping. I moved the dose to the morning and Boom!, good sleep.
That's a good point. There's also a bunch of other confounding factors which affect sleep. E.g. circadian rhythm, variance of sleep/wake times, how physically tired you are, how much recent REM/deep and whether there is a deficit, how stressed you are, screen usage before bed, eating close to bed time, exercise close to bedtime, etc... Maybe the Vitamin D3 taken close to bedtime is enough to tip some people over the edge to some kind of insomnia, given the presence of other melatonin inhibitors.
Changed to take the supplements in the morning and the insomnia went away.