Magic comes in two main forms: combat magic and ritual magic. Ritual magic is concerned with the casting of grand spells - think esoteric magic circles, weeks of mystical chanting, and the sacrifice of magic resources (or slaves!) in return for a tremendous effect. These are the spells that you cast on the strategic map of Dominions 5 and play a major role in almost every nation's toolkit.
In order to cast a ritual, you require four things: a mage with sufficient 11111111 magic paths to cast the ritual; a laboratory to staff the mage in while they cast; the magic gems to fuel the ritual; and the research to know how to cast the ritual.
You can order a mage to cast a ritual by opening their command menu and selecting 'Cast ritual spell'. This will display all the rituals you have researched which your mage is capable of casting. Select a spell to begin the ritual - if you have insufficient resources, you will be told so and the commander will be reset to the default 'Defend' order.
If you have everything you need, the mage will be set to 'Cast ritual spell'. This is all they can do for the turn; if you issue any other order they will stop preparing to cast and you will need to reissue the order (no resources are lost, however).
When you end your turn, any mage you have ordered to cast a ritual will permanently consume the required resource and cast the spell. This occurs at a specific point in the resolution, so it might be worth familiarising yourself with the turn order sequence.
The next turn, the mage will be once more set to the default Defend order, ready to carry out your next command. If, however, you select the 'monthly ritual' checkbox on the ritual casting screen, they will keep the same order and continually cast that ritual every month as long as they have the gems to do so.
Rituals have all sorts of effects, and it's hard to sum them up here, but in general casting a ritual spell will do one of the following (with examples):