The subjunctive is a mood used to describe things that are more abstract than the indicative; feelings, desires, doubts, fears, the abstract and the unknown. There are a series of phrases that trigger the use of the subjunctive, and it's also used with 'ojalá'. It usually follows the indicative mood in any tense, with the two clauses separated by 'que'.
A useful acronym to remember when we use the subjunctive is WEIRDO: Wishes, Emotions, Impersonal expressions, Recommendations, Doubt/Denial and Ojalá.