Its really a great question and let us go by simple definition.
Defination:
As per what wikepedia says:
A yo-yo (also spelled yoyo) is a toy which in its simplest form is an
object consisting of an axle connected to two disks, and a length of
string looped around the axle, similar to a slender spool.
Working:
But what really makes it work? In simple it is energy converting machine.
If we see at first yo yo has some potential energy as it is above the ground. But when we release yo yo. It converts that potential energy to kinetic energy. When a yo yo spins at bottom generally its the kinetic energy of rotation.

In general we can say that yo yo can spin up and down forever but what makes it stop is :
string is attached with plastic axle therefore there is friction force acting between two objects.
And the air resistance as yoyo wheels also rub air which we are not able to see.
The image of simple yoyo when it is opened:

Mathematical:
It is simply solved as I am no expert.
Diagram below this:
$$-mg+T=ma$$
$$\tau=I \alpha ,Tr = I \alpha$$
$$v=-r \omega , a=-r \alpha $$
From 2 and 3
$$a= -\frac{g}{1+I/mr^2}$$
$$I = \frac{1}{2} m R^2$$
$$a=- \frac{g}{1+ \frac{1}{2}(R/r)^2}$$

There are clutch yoyo which acts quite interesting which acts because of centrifugal force and they call them centrifugal clutch. What makes this yoyo different is that there is one spring mechanism attached inside the yoyo. Whenever the yoyo is rotating slowly then springs comes contact with the axle and makes it fall back on the string. But the main advantage is that if the yoyo is rotating much faster, then the weights fly out from the axle (weights are attached with spring) because of centrifugal force. Now there is nothing to clamp and it is free to move at the bottom and when it got slow down then it come in contact with axle and got back up because of friction.
Here's the photo showing this mechanism :

Here at this image you will notice how clutch yoyo works. If you see when you spin hard those two solid bars go away but if you will flick it will come back automatically to you.
