"Under the weather" means feeling unwell, ill, or slightly off. It typically describes mild illness rather than serious sickness: "I'm a bit under the weather today" suggests a cold, tiredness, or low energy — not a hospital visit. It can also describe emotional low spirits or general poor condition.
The phrase almost certainly comes from sailing. Life at sea exposed sailors to harsh weather conditions — storms, cold, spray, and rough seas could all make a sailor sick. When a crew member was ill or suffering from seasickness, they would be sent below deck to recover. Below deck placed them physically "under the weather" — sheltered from it, but also subordinate to it, at its mercy.
A fuller version of the phrase — "under the weather bow" — appears in nautical writing. The "weather bow" is the side of the ship facing into the wind and weather. Going below the weather bow meant going to the least stable, most uncomfortable part of the ship during rough conditions. Being sent there when unwell made an already miserable experience worse.
The phrase first appeared in print in American sources around 1850. It was well-established in general use by the latter half of the 19th century and had spread from naval slang into everyday language.
English has inherited a vast number of nautical expressions: "know the ropes," "take the wind out of someone's sails," "three sheets to the wind," "on an even keel," "plain sailing," and "by and large" all come from seafaring. A language built by a maritime nation carries the sea in its vocabulary.
Primarily yes, but it can also describe someone who is emotionally low, dispirited, or generally not at their best. The sense is always one of being below par in some way.
It is informal. You would use it in casual conversation or writing, not in a formal medical or professional context.