Dear student,
Gold leaf electroscope is a simple device to detect the presence of charges on a body. When a charged body is brought near a golden leaf electroscope, the charges flow(mainly electrons) either from the body or to the body, depending upon the charge of the body.( The electrons will flow from the body if it is negatively charged and to the body if it is positively charged). This flow of charges will leave the golden leaves charged. Both of the leaves will acquire same charge. As same charges deflect each other, the leaves are separated/ attracted. This is how an electroscope works.
Now to answer your question, it is said the leaves collapse as the hand is brought to the electroscope. This is because the hand must be positively charged. As the hand is positively charged, the electrons from the leaves flow towards the body, thus decreasing the density of negative charges(electrons) on the leaves. This will reduce the repulsion between the leaves and will bring them close to each other. As the hand is removed, charges are distributed uniformly as before, thus bringing back the leaves to the same position.
thank you.