When you face a criminal charge in court, the burden of proof is on the prosecutor. That means that the prosecutor must offer evidence to show that you committed the crime.
One of the best ways to defend yourself is to prove that the evidence the prosecutor wants to use is inadmissible. Cornell Law School defines inadmissible evidence as that the jury cannot consider.
Some evidence may not be legal because of the way authorities received it. For example, if a person gives a statement without receiving the proper notification of rights, then the law says that statement is not usable in court.
Prejudicial evidence is inadmissible because it is unfair or it could cause confusion. For example, if you had an affair in your marriage that does not relate to the charges you face and the prosecution introduces that, your defense team may object because it is prejudicial and can cause the jury to have certain feelings against you that may impact their decision.
Hearsay is evidence that comes from another person but that person does not present it in court. For example, if, while on the stand, a witness states something that someone else says, this is hearsay. There is no way to substantiate that what is said is true, so it cannot become evidence.
Any evidence that is not relevant to the case is typically inadmissible. The judge has the ultimate right to determine if the evidence is relevant. Sometimes relevance and prejudice can overlap. The example of your affair may also lead the judge to rule is irrelevant.