This kind of letter should typically be brief and straightforward. Unless they have told you specifically what should be in the letter, you can write:
To whom it may concern:
Please be advised that, as a Muslim, my religious observance precludes me from living on a coeducational campus. As per the advice of [person or office who told you to write the letter], I am writing this letter to request an exemption from the on-campus living policy.
Thanks for your consideration,
If you want, you can also include contact information for a member of the clergy (i.e., a religious leader) who knows you and can vouch that you do, in fact, have such a requirement. (Sometimes this is required as a matter of policy; for example, those who cannot take the SAT on Saturday due to religious observance must provide a letter from clergy attesting to this.)