You must have an unlocked phone if you would like to use an eSIM on the device.
How to check if your device is unlocked on iPhone:
1. If your device is on iOS 14 and above, open Settings > "General".
2. Click on "About"
3. Scroll to find the part highlighted "Network Provider / Carrier Lock".
If it says, "No SIM restrictions" Then your device is unlocked and you are able to download eSIMS straight away.
If your device is locked to a specific network, you will need to contact your mobile carrier to get your device unlocked. If your device was recently unlocked, you may have to wait for the eSIM support to become available as your carrier might disable it for a period of time for security reasons.