Maybe. Many people are looking for some "magic pill" to "boost their immune system". There is no such pill. However, there is a way to boost your immune system, live a healthy lifestyle. Proper diet, proper sleep- wake cycles, healthy environment, proper exercise are the foundation of good health and good immune health. If you get better sleep with your sleep aid this could be helpful to your immune syst.
Maybe a little bit. A body that is very fatigued, due to a lack of sleep, excess stress, being overworked, etc... May get sick more easily. If a person uses sleep aids to help him fall asleep, have a normal type of sleep, or stay asleep longer, he will no longer have a "lack of sleep". His body and its immune system will become more "normal", so his chances of getting sick will be similar to that of a healthy person.