If it is the passcode to unlock the iPhone's screen:
See these instructions, keeping in mind that if you don't have a backup all data will be lost on that device (except those that you eventually synced to iCloud):
If your device is running iOS 15.2/iPadOS 15.2 or later, AND if you have created a backup to iCloud, you don't need a computer:--> How to reset your iPhone, iPad, or iPod touch when you forgot your passcode - Apple Support
Shouldn't be this case (iOS/iPadOS earlier than 15.2), you need a computer. If you don't have a computer, borrow one from your friends/relatives/neighbors or ask for help at an Apple Store or Authorized Service Provider, then read these suggestions.
Given that to remove the existing passcode you must connect your device via USB to a computer (a Windows PC running the latest iTunes version, or a Mac, which can run iTunes or Finder, depending on the macOS installed on it), pay attention to the specific gestures that you need to perform while connecting your device to the computer.
These are the instructions to re-gain access to your iPhone:--> If you forgot your iPhone passcode - Apple Support
If it is the password related to an existing Apple ID on that device:
If you are talking about "activation lock" (an anti-theft measure), AND if you cannot remember the old Apple ID & Password (even using these instructions:--> If you forgot your Apple ID email address or phone number - Apple Support or these:--> If you forgot your Apple ID password - Apple Support ) neither we, just users like you, nor Apple can help you, sorry, unless you are the original owner and you still have the proof of purchase (receipt/invoice reporting your device’s IMEI or Serial Number). Should be this case, start your request using this link: https://al-support.apple.com/#/additional-support
Shouldn’t be this case, activation lock can be removed only by the previous owner, with the credentials that were used to activate that iPhone/iPad. Without those credentials, that device is useless to you.
You can also take a look at this support article:--> How to removeActivation Lock- Apple Support
Regards
Giulio