The sources of energy of solar activity are analyzed. The primary source of solar energy is the core of the Sun, where as a result of the reactions of thermonuclear fusion, energy is released in the form of γ-quanta and neutrino particles that propagate outward. At approaching the surface, the temperature is rapidly decreasing and at the same time the opacity of the substance of the radiation zone steadily increases, resulting in the creation of conditions for the emergence of a convective energy transfer at a distance from surface of about 0.3 radius of the Sun. Above this boundary lies a layer called the convection zone. The existence and localization of the convection zone of the Sun is determined by two reasons: the first – the structural (radiative) temperature gradient increases due to increased opacity when the temperature drops; the second – the adiabatic gradient of the temperature of the floating elements reduces its value in the zones of partial ionization of hydrogen and helium. It is the convection zone that plays the role of the landfill, where the main processes are born, which are responsible for the cyclic manifestations of the Sun’s activity. However, part of the convective flow of energy coming from the interior of the Sun, accumulates and is carried upwards in the “magnetic form”. An important specific property of magnetic energy transfer is manifested in cyclic changes in most of the phenomena generated by magnetic fields, which are called magnetic activity of the Sun. The main mechanism providing the cyclic nature of the fluctuations of magnetic activity is the turbulent dynamo, localized in the convection zone. The most favorable place for the generation of a toroidal magnetic field, on which the intensity of spot formation depends, are the deep layers near the bottom of the convection zone, covering the layer of permeable convection (convective overshoot layer) and the tachocline. Overshoot creates the necessary conditions for the formation of a layer of long retention maintenance of magnetic fields, whereas in the tachocline, due to the sharp decrease in angular velocity in the presence of a weak poloidal field, a powerful toroidal field is effectively generated. Parker buoyancy of this field dominates over the effects of anti-buoyancy. Therefore, eventually, toroidal field rises to the surface and forms magnetic bipolar groups of sunspots. An important factor of physical processes in the deep layers is also the meridional flow directed to the equator, which, within the framework of the hydromagnetic dynamo model, provides the migration of toroidal fields from high latitudes to low ones. The author’s recent studies on the role of the deep layers of the solar convection zone in explaining the observed phenomenon of double peaks of the cycle of sunspots are noted.