As far as I know, the titan shifters inherited their power when Ymir Fritz died and her power was split between her 9 descendants. But what about the mindless titans, those who arent titan shifters and all the time titans, what's their origin and why were they created?
Basically it goes like this
All of the Eldians (Descendants of Ymir) have the possibility to be a titan shifter. But in order to use the non-titan-shifters, Marleyans(Their enemy which defeated them in the past) invented something like a syringe that when injected to an Eldian, turns them into a titan and because they don't have the original titan powers, they cannot control the titan and turn into a mindless titan forced to see people die by their hand and not be able to do any thing.
But if you are asking what the mindless titans are doing outside of the walls
The king of the Eldians and the possessor of the Founder titan power moved his people to an island called the paradise island and created the walls to keep enemies and the ones who wanted to miss-use the titans, away. But Marleyans built a wall of their own around the island and any of the Eldians that was living among the Marleyans and did an unforgivable crime was turned into a mindless titan and was released into the island and outside the original walls.