This is a quite complicated area of evidence law in the U.S. as there are many statements which are inadmissible under the hearsay rule, but there are also many statements that would otherwise be hearsay that fall within exceptions to the hearsay rule.
In U.S. federal court practice, hearsay is governed mostly by Federal Rules of Evidence 103, 104(a), 201, 801-807, and 1101.
Most state court rules of evidence in the U.S. with regard to hearsay closely track the Federal Rules of Evidence. Some states do not follow this pattern but are substantively very similar as the Federal Rules of Evidence largely track of the common law rules of evidence before they were codified.
Rule 801 provides two exclusions from the definition of hearsay and a foundational definition. Rule 802 prohibits the introduction of hearsay into evidence unless an exception applies. Rule 803 provides 23 exceptions to the rule. Rule 804 provides five more exception to the rule. Rule 807 provides a final residual exception. So, in proceedings where the hearsay rule applies there are 31 main exceptions to the general rule, in addition to the argument that the general rule does not apply, but this still excludes lots of statements. Rule 201 (judicial notice) is another exception.
Some of the main reasons to admit hearsay are that:
It is not offered for the truth of the matter asserted (e.g. to prove the someone was present and talking at a place not that what they said was true, or to prove that someone said something defamatory or fraudulent, or to prove the someone made a "verbal act" with legal significance like agreeing to a contract or ordering someone to do something).
It is a statement of a party opponent or someone affiliated with a party opponent (i.e. someone affiliated with the other side in the lawsuit or criminal case).
It is a prior statement of a person made under oath and subject to cross-examination.
It is a business record or public record or an "ancient document" (currently ancient means before 1998 in the federal courts, and typically more than twenty-years old in the state courts).
It is a market quotation.
It is a statement made describing things "in the moment", for medical diagnosis, or when the facts were fresh in the "declarant's" mind.
It pertains to rights in real property, or to family relationships.
It is a statement contrary to the interests of the person making it.
It is a statement made when the declarant's death was believed to be imminent (i.e. a dying declaration).
It is a statement made against someone who caused the witness to be unavailable.
There are reasons that the statement is reliable and the intent to provide the statement is cleared with the court in advance.
The matter upon which a statement is made is of general public knowledge not reasonably subject to dispute, is easily confirmed without doubt by a court, or is from a learned treatise.
Hearsay objections are also waived if a timely objection isn't made to them. See Federal Rule of Evidence 103. And, courts have some discretion to allow hearsay testimony on immaterial matters or matters that are not seriously disputed in the case for expediency's sake.
Rules 104(a) (excluding preliminary matters) and 1101 set forth when the hearsay rule applies and when it does not. Rule 1101 excludes from the rule a variety of preliminary matters, mostly in criminal cases such as:
grand-jury proceedings
extradition or rendition;
issuing an arrest warrant, criminal summons, or search warrant;
a preliminary examination in a criminal case;
sentencing;
granting or revoking probation or supervised release; and
considering whether to release on bail or otherwise.
Rule 805 governs the complicated situation of hearsay within hearsay. Rule 806 coordinates the hearsay rule with rules on how it is proper to introduce evidence about the credibility of a witness.
There is also a constitutional rule of criminal procedure, called the "confrontation right" that established minimum standards for the exclusion of hearsay evidence in criminal trials even when a court's procedural rules do not exclude it.
Most states also have a hearsay rule pertaining to oral promises made by dead people called the dead man's statute, and limitations on introducing oral statements related to written agreements called respectively, the parole evidence rule and the statute of frauds.
In contrast, in the U.K. courts, roughly speaking, hearsay is generally admissible when the person making the underlying hearsay statement is available to testify, or is unavailable, which subsumes a large share of the U.S. hearsay rule, and makes much more hearsay admissible. U.K. practice would also allow admission of almost anything without a U.S. hearsay exception since they are derived from British common law evidence rules related to hearsay.
The main purpose of the hearsay rule is to prevent a defendant in a criminal case or lawsuit from being denied an ability to cross-examine witnesses in court because they would like to present evidence by affidavit or letter instead, effectively placing that burden on the prosecution in criminal cases, or on a plaintiff in simple civil cases, rather than forcing the defendant to pro-actively subpoena witnesses for the other side in the case. The rule has a broader sweep than that, but that is its core purpose.