Whenever Brahman "experiences" sorrow and suffering, it has a purpose behind it.
In the Rama avatAra, the supreme brahman Vishnu experienced a lot of sorrow and suffering. But according to the Srimad Bhagavatam, all this sorrow and suffering experienced by Sri Ramachandra is only as if. The intention is for God to teach the world the negative effects of getting attached to women.
http://vedabase.net/sb/9/10/11/en
rakṣo-'dhamena vṛkavad vipine 'samakṣaḿ
vaideha-rāja-duhitary apayāpitāyām
bhrātrā vane kṛpaṇavat priyayā viyuktaḥ
strī-sańgināḿ gatim iti prathayaḿś cacāra
SYNONYMS
rakṣaḥ-adhamena — by the most wicked among Rākṣasas, Rāvaṇa; vṛka-vat — like a tiger; vipine — in the forest; asamakṣam — unprotected; vaideha-rāja-duhitari — by this condition of mother Sītā, the daughter of the King of Videha; apayāpitāyām — having been kidnapped; bhrātrā — with His brother; vane — in the forest; kṛpaṇa-vat — as if a very distressed person; priyayā — by his dear wife; viyuktaḥ — separated; strī-sańginām — of persons attracted to or connected with women; gatim — destination; iti — thus; prathayan — giving an example; cacāra — wandered.
TRANSLATION
When Rāmacandra entered the forest and Lakṣmaṇa was also absent, the worst of the Rākṣasas, Rāvaṇa, kidnapped Sītādevī, the daughter of the King of Videha, just as a tiger seizes unprotected sheep when the shepherd is absent. Then Lord Rāmacandra wandered in the forest with His brother Lakṣmaṇa as if very much distressed due to separation from His wife. Thus He showed by His personal example the condition of a person attached to women.
In the example given in the above question, the purpose of brahman experiencing sorrow on separation from his devotees is to show the world that he truly cares for his devotees.