How to track text messages on iPhone without being detected?

Apple devices do provide a workaorund it. If you want to track text messages, you can add their iCloud account to your device and sync all the data.

Settings → tap the Apple ID name
iCloud → Messages
Toggle Sync this iPhone ON
Do the same on the second device using the same Apple ID.

On both devices:

Settings → Messages
Turn iMessage ON
Confirm that the same Apple ID is selected under Send & Receive

After doing this, you will be able to monitor text messages without physically accessing the other phone.