In a court of law the only admissible evidence is relevant evidence. Relevant evidence is pertinent evidence. Whether something is pertinent or not depends on the matters required to be proved (defined by the issues).
While making allowances for the more or less incoherence of any witness, it is the function of the court (and the advocates) to address only the issue or issues in the case and, for the advocates, to only adduce evidence directed to those issues. All other evidence is irrelevant.
If irrelevant evidence is admitted and received by the court, grounds for reversal on appeal exist.
The purpose of a trial is to do justice between the parties. This is especially so in a criminal prosecution. This overriding objective is so strong that the court will on occasion, exclude even relevant evidence (People (AG) v O’Brien [1965] IR 142)