I couldn't tell you more at present. In my opinion it serves to intensify a bond through effort and sacrifice.
It is not a bad thing in itself, take for example physical activity, or working with the Gods. You make effort, you use time and energy to create something positive, and on top of that it intensifies and creates a bond.
But the way muslims and christians do it is completely wrong and useless. You literally create problems for yourself, and hope that your 'god' will help you solve them, or that hurting yourself is a necessary thing for whatever reason you can think of. These exertions do not serve to improve you like the exertions of training for example, but serve to make you a pitiful being, and they strengthen the bond by making you fall to your knees because of how much your life sucks (desperation). And if the negative situation you've created for yourself doesn't improve? Then it means that you haven't deepened your practices enough (which they created the damage in the first place), and so you have to do even more.
This eliminates responsibility. As soon as 'god' sees how devoted I have been in destroying my life with his practices, he will save me and give me heaven.
The example above does not only refer to 'ramadam' but in general to other practices that make you pitiful, such as poverty is a virtue or the like.
There are others examples of certain medioeval christian cults, where for the great sin of existing, you litteraly torture your self phisicaly and mentaly for all your life.
How much retarded do you have to be for believing that destroy your existence will make you reach the higher dimensions of existence (heavens)? Maybe it's all a simulation run by this lovely "god", where everyone is tested for paradise, and put in universe where all that you have to do is destroy your existence and suffer all your life. Maybe I will be sent in a brand new paradise multiverse if I follow all this "lovely dictates" of "god", or maybe these are all jewish lies to conquer and enslave you, who knows?
But after all, 6.000.000 jews died in a immaginary holocaust, i think it's better to not question them and return to my "multiverse paradise" theory where I will destroy my self.
(I have included some christian mindset, millions people believe in this).
A concept necessary to grow and develop healthy and productive relationships, turned into a completely retarded system to destroy your life.
With Gods, however, we make sacrifices (time, energy), learn responsibility, improve and grow exponentially.