Before you start: Your iPhone needs to run iOS 12.1.1 or later to support eSIM technology.
First of all, check your plans
Your iPhone must be either unlocked, or both cellular plans must be from one carrier. Here is more about unlocking an iPhone.
Both plans must be set up and ready to use.
Your carrier/carriers must support Dual SIM with an eSIM.
If a CDMA carrier provides your first SIM, your second SIM won't support CDMA.
If you can't set up your eSIM
Make sure that your iPhone plan is suitable for Dual SIM service. Check with your carrier for that.
If you use an enterprise or corporate cellular service plan, check with your company or carrier to see if they support this feature.
Make sure that your carriers provide coverage in your area. Also, there should be no service outages.
Make sure that your cellular plans are configured, ready to use, and are not blocked because of some billing issues.
If you still can't set up your eSIM, contact your carriers for support.