When a text message arrives the iPhone displays it on the screen, even if your phone is locked, by default.
To keep messages from prying eyes, open Settings, Notifications, then Messages. Turn off Show Preview to hide the text from view.
This is also possible for email messages. Open Settings, Notifications, then select Mail. Tap on your account name and turn off Show Preview. Now, neither texts or email previews will appear on your device when received.