The answer to the question is straightforward and because it is pretty obvious this is going to be a short post! Think about the typical home: there is nothing in it which is remotely like the soil (the earth and sand) of the outside world, on which cats inherently go to the toilet.
Domestic cat inherit the desire to use a substrate (material on which to poop and pee) which is found outside because they are domesticated wild cats. That behavioural characteristic is hard-wired into their brain and it will probably never fade away. Perhaps it might in a thousand more years of domestication.
As domestic cats inside the home search for soil on which to poop and pee they will settle on the nearest thing to it which is cat litter. They’ll find it quickly and instinctively.
You could use soil or sand but these are less effective from the human standpoint because they are non-absorbent which means there are odours. People don’t like that in their home.
The commercially produced cat litter substrate is a designed to meet the requirements of both cat and caretaker.
When cats go to the toilet outside the litter tray they do so for a variety or reason the most common of which is because they are marking their home range with pee usually and sometimes with poop. It may be a health issue such as cystitis.
When a cat marks territory they are not searching for soil onto which they poop. They want the smell of their poop and pee to be recognised. It is a calling card. There is no need to bury it in soil or cat litter. So they don’t bother to use the litter tray. Also they mark their home range in places where the marking has more effect which will often be where the litter tray is not found.