Some courts have a duty to decide every case brought before them that properly invoke their subject matter jurisdiction and their territorial jurisdiction. In Texas state courts, these would be municipal courts, small claims court, justice-of-the-peace courts, county courts themselves or, where they are substituted for by county courts-at-law, county-courts-at-law, state district courts, and courts of appeals. In the U.S. federal system, the courts are bankruptcy courts, U.S. district courts and U.S. circuit courts of appeals.
A long-standing principle of Anglo-American or common law is that a court does not give advisory opinions. A good effect of such a rule-- likely the original reason for it-- is that deciding a case arising from particular facts is much easier than deciding a case on the basis of pure abstractions. Compare how much trouble philosophers have with reasoning about questions for which legal reasoning is nowhere near as complicated. A bad effect of this rule is that one often cannot challenge the propriety or constitutionality of a law without violating it, and then urging the impropriety or unconstitutionality as a defense to being punished. That one must risk punishment to challenge a statute, regulation or practice, makes people less inclined to challenge the interpretations of statutes, regulations, or practices of those with power.
This rule appears to have at least two apparent exceptions. The first is the remedy of declaratory judgment. In such a situation, someone asks a court to make a declaration which another party opposes. This form of relief appears to have been urged on legislatures by insurance companies to allow insurers to sue as plaintiffs rather than having to wait for the plaintiff or plaintiffs to sue the companies as defendants. If a declaratory judgment does not decide a live controversy, such as whether an insurer must provide a legal defense for its insured, the suit is not allowed. It can't be used to decide a tax dispute or a criminal law dispute. So this exception to the rule is more apparent than real. The second apparent exception is certified question practice. The Texas constitution provides that the Texas Supreme Court may, but does not have to, answer a question of law put to it by a federal appeals court. In civil disputes in which the amount in controversy is not small that come before a federal court because none of the plaintiffs come from the same state as any of the defendants, the federal court is supposed to use state law rather than federal law to decide the case. So far, so good, but what is a federal court to do when there is no state case showing what state law is? Generally, the federal court has to make an educated guess as to what the state law would be. Unfortunately, it is possible that the federal court follows one doctrine, and later on, the state courts follow a different one. Certified question practice allows a federal appeals court to ask the Texas Supreme Court what the answer is. The feds can ask, but the Texas Supremes don't have to answer. When they don't answer, SCOTX makes the effort to get the ruling a waste of money and effort. Still, before the state constitutional amendment, SCOTX had ruled that answering a certified question was improper because the answer would be an advisory opinion. Notice, though, that a certified question grows out of a live dispute in the federal court, and the facts in that case can aid the state court by giving facts to the dispute, that an abstract question does not have.
A court can refuse to hear a case when the parties are going to have a have a dispute, but have not had the dispute yet or that important facts about the dispute are not presently known. Such a case is said to be unripe.
A court may also refuse where circumstances have left nothing to be corrected in an old dispute. For example, two parties may dispute ownership of property on the bank of a river, If the river floods, and the disputed land is washed away to the sea, no property ownership question may be left. Such a case is moot.
You might ask, how can the United States Supreme Court decide cases such as abortion cases, since gestation generally takes nine months, but hardly any case can get through trial, court-of-appeals review, and Supreme-Court review in less than nine months? It can because such situations are subject to repetition, but evade review. In the famous or infamous Roe v. Wade case, that the plaintiff had had an abortion in another state as to the abortion she sought in Texas, but was still capable of future pregnancies, that capability for future pregnancies gave her enough of a continuing interest in the matter to keep up her suit.