There is no legal requirement for that, but:
- if nobody on market want your stock, there is no point going public. Keeping it private is more beneficial for everybody.
- The board need to answer shareholder. Unless you want endless EGM and shenanigans, you want to maximize the profit.
In theory, you can have a public traded company don't aim for profit. But I can't see how we get there... I guess if you have a money printing machine, you could out complete all the for-profit investor on the market....