Why did Krishna steal the Gopikas clothes from the tree when they were bathing in the little river?
It was just a pastime of Lord Shri Krishna to test and teach the gopis a lesson. The gopis loved Shri Krishna very much and desiring to obtain Him as their husband they performed Kātyāyanī (one from of maa Durga) vrat for a month. On the final day of the vrat finishing their puja, the gopis went to Yamuna for bathing:
evaṃ purṇe ca māse ca samaptidivase tathā
snātuṃ prajagmugārpyaśca vastrāṇyādhyāya tattaṭe
Thus after the passing of one month, on the day of the completion, the gopis went to Yamuna for bathing carrying with them clothes, jewels, and many other things. [BVP - 4.27.8,9]
In a sportive mood they put their garments on the shore and went into the river without clothes. However, entering into water without clothes is offensive to varuna (the god of water). So to teach them a lesson, Shri Krishna and their friends took their clothes and hid at a distance:
vastrāṇādāya te sarve tasthurekatra dūrataḥ
śataśaḥ punjikāstatra sthāpayāmāsurunpukhā [BVP - 4.27.18]
Collecting the garments they went away and hid at a distance. Thus they gathered and created a heap of hundreds of clothes there.
Then Shri Krishna told the gopis:
saṃkalpite vratāha ca māse magalakarmaṇi
yūyaṃ nagnā: kathaṃ toye vratāṃgahanikārikāḥ
vrate tu nagnā yāsnātitāṃ ruṣṭovaruṇaḥsvayaṃ [BVP - 4.27.21,23]
You have vowed to observe the auspicious vrat for one month. Then how are you bathing in the water naked which is destroyer of the fruits of the vrat? Varuna (god of water )himself gets angry on him/her who baths naked in the water during the vrat.
When gopis found out that Shri Krishna and His friends had taken their clothes, they requested Shri Krishna to give them back:
O Śyāmasundara, we are Your maidservants and must do whatever You say. But give us back our clothing. You know what the religious principles are, and if You don’t give us our clothes we will have to tell the king. Please! [SB - 10.22.15]
Then, to test their surrenderness Shri Krishna spoke them as below:
The Supreme Personality of Godhead said: If you girls are actually My maidservants, and if you will really do what I say, then come here with your innocent smiles and let each girl pick out her clothes. If you don’t do what I say, I won’t give them back to you. And even if the king becomes angry, what can he do? [SB - 10.22.16]
After the gopis did as Shri Krishna told them, He returned their clothes. Thus after lovingly teasing and testing the gopis, the Lord granted their desire and told them that their wishes will be fulfilled:
Go now, girls, and return to Vraja. Your desire is fulfilled, for in My company you will enjoy the coming nights. After all, this was the purpose of your vow to worship goddess Kātyāyanī, O pure-hearted ones. [SB - 10.22.27]
Note: “The question: Why did Krishna steal the Gopikas clothes from the tree when they were bathing in the little river?” is licensed by Stack Exchange Inc (https://hinduism.stackexchange.com/); user contributions licensed under CC BY-SA.