Dear Student,
The sun provides heat which causes liquid water to evaporate into vapour, which rises high in the sky to form clouds. These clouds move over the different places and drop rain. The rain falling on the high ground in hill areas flows down as river. In order to produce electricity a high rise dam is built up to stop the flowing river behind the dam. Due to this a large reservoir is built up behind the dam. In this way the K.E. of the flowing river is converted into P.E. of water stored behind the dam. A hydro power plant converts the P.E. of water stored in the reservoir of a tall dam into electrical energy.Thus ultimately sun is the source of hydro electrical energy.
Regards.