Leaving religion aside, in mysticism morality and moral behaviour is just a means to an end. The general force behind or within the universe takes proper care of all of its creatures. So if we are to better join that force from the inside, we should become more like it and imitate it.
There are 2 ways to imitate and join it. One way is to increase our love for it, or fall ever increasingly more in love with it and the other way is to express that love by serving it through its creatures.
The best morality, the best set of moral codes has to fulfil these 2 aims by making our do's and don'ts more detailed and explicit in a logical way.
So morality is not a set of codes that God drops from the sky, but rather it can be and has been discovered by those mystics who learnt the proper way how to realise your true Self.
Of course in religions they have myths about how their particular sets of moral codes were "revealed".