How to sync or backup iPhone contents to new Mac
I logged in, authorized and used &quot;Transfer Purchases from iPhone&quot; as described in @appleluntanyi's answer and the linked article.
When syncing apps, I got the dialog

Are you sure you want to sync apps? All existing apps and their data
on the iPhone &quot;iPhone&quot; will be replaced with apps from this iTunes
library.
Cancel / Sync Apps

When I synced anyway, it did in fact keep the app data, but it messed up the icon order and grouping.
So I would recommend syncing the iPhone to your old computer just in case, taking screenshots of your home screens if you want to remember how they were arranged, doing the login/auth/transfer as described in the article, and then syncing despite that incorrect dialog.
You can e.g. transfer the screenshots to the computer through Preview.app: File &gt; Import from iPhone….