The purpose of setting up the treasury function is to manage risk.
In a perfect world, shareholders will be well-diversified and so manage risk themselves and do not need the company to do it for them (as I explain in my lectures on CAPM). In that case there would be no point in spending money creating the treasury function if there is nothing to be gained for the shareholders.