If you forget the passcode you will have to factory reset.
Factory Reset:
Shut off device. Hold Power, Vol Up, and Bixby buttons until you see the Android Mascort with Blue Background. It will prompt you options for your device after it completes its boot.
You will lose everything. If you did input a Gmail account on the phone it will lock itself during the set up process unless you have the credentials for the phone.
Good Luck.