The meaning of this phrase has changed from its origin. It originally meant to take cover under the weather deck on a ship. Unfortunately taking cover under the weather deck was never a positive, it was called the weather deck for a reason - it's where all the weather hits or collects! As years passed the phrase morphed into what we know it to mean these days, to feel ill or depressed. I can see how it turned into that from the weather deck through someone getting ill from being "under the weather deck."
For more on this phrase starting off as one thing and becoming a different thing click here.