When you receive a message on your iPhone, it will appear on your lock screen. You could unlock your iPhone and open Messages to reply, or you can just reply right there from the lock screen. But this means anyone else can reply to your messages right there from the lock screen, too.
If you want to prevent anyone from pranking you and possibly causing a serious misunderstanding, you can turn this feature off.