A threat is a type of communication. It is a warning. It is a behaviour which almost all advanced animals have. In humans it is often verbal (spoken). The dictionary definition of "threat" isː
Threats evolved because actual fighting often damages an animal, and a damaged animal is at risk. On the other hand, animals compete for food, territory, and mating for example.
Because humans have complicated brains, their use of threats may be deliberate, and may be spoofs or jokes. Humans make threats verbally, but words are not automatic. If one person treads on the toe of another, the might say "Ow" by reflex. That response is not a threat. But if they say "do that again, and I'll [whatever]", that is a threat. In many cases the threat is not believed, or may even be a joke. Like other communications, a threat has a context, and the context decides its meaning.
A child who says "I'l tell my dad" may learn from the sarcastic reply "I'm so scared!" that the threat is what is called an "idle threat". An idle threat is one that promises harm which cannot or will not happen.
A threat to do harm may be mixed with an offer to do good. This is called a conditional offer, or throffer. The threat part may be implied, but still effective.
Some countries, such as the United States, have a legal concept of "true threat". A true threat is a threatening communication which can be prosecuted under the law.
A threat can describe a situation of danger. For example a "terroristic threat". Many countries have a system where the government can adjust its security by having official threat levels.