To setup your iphone so that it doesn't require a passcode to unlock if it has been closed in within a specified number of minutes:
Steps:
1. Goto: Settings > Touch ID and Passcode > Require Passcode.
2. Set the passcode lock delay time.
Note: by default you will see 'Immediately' next to Require Passcode. This means that as soon as your device locks, your passcode will be enabled.
For more information, see here.