Even though the iPhone and iPad run a similar OS and many of the same apps, they don't compete in the same field. Smartphones are essentially a necessity for most people today given how many roles they play: calling and messaging, music player, GPS, entertainment, camera and much more.
An iPad isn't nearly as vital. For many people, a tablet is a secondary device for streaming, reading and maybe taking notes. They can be great for students and those in creative fields, but they don't feel necessary in the way phones do. You could opt for a "phablet"-sized phone, a Chromebook or even a laptop like the surprisingly solid MacBook Neo for the same purposes.
Because of all this, Apple has good reasons to offer a low-cost iPad. Fewer people would buy a tablet if the starting price were prohibitively high, which means the company would miss out on newcomers to the Apple ecosystem spending on services like iCloud and Apple Music. The iPad also competes against Chromebooks in the education market, where Apple wants schools to buy its devices and get them into families' hands.
The iPhone represents Apple's highest source of income by far, meaning it's sensible for the company to spend the most time and money improving it. Apple has always positioned the iPhone as a premium phone and knows what people are willing to pay for it. Selling an ultra-cheap iPhone would devalue the framing Apple has built up over decades; even the "affordable" iPhone 17e is hundreds more than budget Android phones.
There's also the matter of how people buy these devices. The majority of US buyers purchase an iPhone through mobile carriers, which offer "free" phones through monthly bill credits in exchange for staying on an expensive plan for several years. This obfuscates the true price. People also tend to upgrade their tablets less often than their phones.