Moonshine is the name for illegally made spirits of non-specific ingredients. So I will answer your question as if you asked something like: "How do I make spirits".
Caveat: Currently, as far as I know, New Zealand is the only country where home distilling is legal.
Drinking-grade spirits are made by taking a fermented liquid, distilling it, discarding the poisonous methanol and other undesirable parts.
Any water-based liquids that have a high sugar content can be used for the fermentation, e.g.:
- Sugar
- Honey
- malt extract
- Molasses
- Fruit Juices (etc.)
Or starchy foods that can be modified to become sugary (typically done with amylase enzymes):
- malted barley (self-modifying at the correct temperature)
- rice
- potatoes (etc.)
This liquid is typically called a "must" for wine making, "wash" for spirits, or "wort" in beer making.
Once a sugary-liquid is created, yeast is added. The yeast consumes the sugar in the liquid as part of a fermentation process, producing (mostly) ethanol and carbon-dioxide. Apart from barley-malt-water (wort), most of these ferments are difficult for yeast, as they do not include nutrients for optimal yeast health. So use more yeast, or add the necessary yeast-nutrients (or both). Generally most yeast can ferment up to about 14-20% AbV without doing anything special.
If we were making wine or beer, the process is just about complete at the end of fermentation. However when producing spirits a final distillation step is used to concentrate the alcohol. Note: it is possible to freeze-distill, but as this concentrates methanol (as well as ethanol) with no removal step, I feel it's not something a complete-beginner should attempt.
The key point to remember is that alcohols evaporate at a lower temperature than water. So if an aqueous alcohol solution is heated to a temperature less than the boiling point of water, the alcohol can be separated as vapour. This process is "distillation". The distillation of "moonshine" is a simplified fractional distillation. The fermented wash is heated to a specific temperature (e.g.: 55-65°C) such that mostly only the alcohols are evaporated from the ferment. A condenser-part at the top of the distillation apparatus cools the alcohol vapour back into liquid, where it is collected. As the temperature of the wash rises, water becomes a larger part of the output. Water is evaporating all the time, it doesn't only evaporate at 100°C.
Depending on the type of distillation equipment used, the spirits may then be re-distilled again. But in all cases, the first part of the distillate is removed as it contains harmful by-products like methanol.
Once the spirit is distilled, it is diluted to a known alcohol level, and then sometimes aged with the addition of wood (e.g.: stored in oak barrels), which changes the colour & flavour.
Depending on the laws of your country, it may be possible to purchase off-the-shelf distillation equipment. Simple searches like "reflux still" or "alembic pot still" will find both instructional-HOWTOs and products for purchase.