Boards and directors due legally have a fiduciary responsibility to share holders. This is covered under countless laws like Sarbane Oxley and many others. This is, in a nutshell, a responsibility to report earnings and expenses completely and acurately. If the company is losing money or making money or just breaking even, the officers and leaders of the company are supposed to follow accepted accounting practices to record and report these things.
You are correct that there is no legal responsibility to maximize profits, but there are legal responsibilities that are fiduciary in nature.
In the US there are state and federal laws that do lay out fiduciary responsibilities for corporations, businesses, and companies. These legal responsibilities have almost nothing to due with what is happening here. They are kind of like laws that require you to drive responsibly when you get a driver's license. There are no laws requiring you to maximise your gas mileage, or to extend the life of your car as long as possible. These things may benefit you as an individual, but they are not legally required.
What this basically boils down to is that Apple is, technically, making almost no profit in Australia and so it pays almost no taxes in Australia. The 'profit' is taken elswhere.
As a hypothetical example, imagine a software company headquartered in California, Utah or Washington state USA. Imagine buyers of the software that live in Brisbane or Sydney Australia. Then imagine a magical Island that charges almost 0% tax on profits.
The hypothetical US software companies will set up subsidaries in Australia and in the magical island. The US software companies will transfer all of the intellectual property rights to the magical Island subsidiary. So the magical Island is the 'owner' of the software rights. The Australian purchaser pays $100.00 AU for a unit of software. The Australian subsidiary records $100.00 AU as net income. Of course the Australian subsidiary purchases the software from the magicle Isle and pays $99.99 Au for it. So the AU subsidiary makes 1 AU cent profit, and is only liable for taxes on that profit.
The software is made, under contract, in the US. The magical Island pays the US company $0.10 US for each unit. It costs the US company $0.09 US to make, so they also make very little taxable profit.
Where is the profit? Seemingly it is in the magical Island. However, what is magical about this island is its tax laws. The laws only require corporations there to pay taxes on sales that happen there!, so the Australian sale does not count towards taxable profits on the magical Island.
All of this is perfectly legal and acceptable under the laws of the countries involved. The reason Austrailia was able to follow the money and figure this out is because these companies are not skirting the law and are fulfilling their legally mandated fiduciary responsibilities. They follow standard accounting practices and record all of these things accurately as required by law.