Why complicate it. If you take all your profits and donate to charity there is no tax.
You could simply create your own church/religion and go from there. I am a Ordained Minister through the online Universal Life Church. You could become your own non profit without the need of a LLC.
Talk to a lawyer.
Please be careful and talk to legal counsel and a CPA on this. Business activities put 501(c)3 status at risk. This is why churches that run day care centers (if they're smart) have that daycare center run by a separate legal entity, not the church. You could operate the multifamily as a business and make donations to the church. But the church can't operate a for-profit business and maintain it's tax-exempt status.
Also, I recommend sitting down with a CPA to find out what tax exemption, if any, you/your business would receive from an in-kind donation of housing for visiting ministries / folks in the program / etc. Donations have strict rules. So, for example, you can't donate a $1M piece of art, and claim that value if the charity is going to sell the art. The donation has to be used in the manner for which it was built. At first blush, donating housing sounds like something you might be able to claim, again, as a donation- not as the church operating the multifamily- but even as a financial planner tax rules make my head hurt so please talk to a CPA before making any promises
Net taxable from rental real estate is generally excluded from UBTI under IRC Sec 512(b)(3).
There is a wrinkle -- if the property is debt financed (i.e. mortgaged), the income may be taxable under Sec 514. There is yet another wrinkle to that wrinkle under the 514 treasury regs -- if substantially all of a property's use is directly related to its exempt purpose, it is not considered debt financed.
It's very possible a church could invest in rental properties to further its tax exempt purpose and not incur UBTI.
Good convo to have with a lawyer and a tax CPA/EA.
This can get really hairy very fast. Talk to CPAs and Lawyers that are experts on these nonprofit issues. Depending on where you live, you may have a nonprofit that provide such advice. I think there might be way to do something like it but there are many, many issues you need to look into. It's a complicated topic.
Disclaimer: While I’m an attorney licensed to practice in PA, I’m not your attorney. What I wrote above does not create an attorney/client relationship between us. I wrote the above for informational purposes. Do not rely on it for legal advice. Always consult with your attorney before you rely on the above information.