Hearsay is the use of an out-of-court statement for the purpose of proving the truth of the contents of the statement. At its most basic hearsay occurs when a witness attempts to testify about information they've been told, rather than events they directly witnessed. The rule against hearsay is intended to prioritize direct knowledge over gossip, though there are multiple Exemptions and Exceptions.
Exemptions = Not hearsay. Examples include terms of a contract negotiation.
Exceptions = Hearsay, but we allow it because it is generally reliable or we have no alternative. Examples include the deposition of someone that has since passed away and therefore can no longer testify themselves.
The above cartoon illustrates the central problem with hearsay. The court would rather have A testify to what he saw than B testify to what he was told.