The derivative of a function (say $f(x)$) is a function of the slope of the tangent line at any given point. It is a generic slope formula for any x value, or instantaneous rate of change. The output of the derivative can be used to make tangent lines. Its notation is $f'(x)$ or $\frac{d}{dx} f(x)$.
A derivative is valid when the function is continuous and when it is differentiable, meaning that both sides of a function approaches the same slope at any given point. If not, this means that there is either a cusp, corner, or vertical tangent present.
Using the slope formula $m = \frac{y_2-y_1}{x_2-x_1}$, you can derive the definition of a derivative using a limit.
$$ \lim_{h \to 0} \frac{f(x+h) - f(x)}{h} = f'(x) $$
The idea is to use a limit to get the instantaneous rate of change of a function as $h$ or the difference between $x_2$ and $x_1$ becomes indefinitely small. Basically get the slope from two points, but the two points are indefinitely close to eachother, or basically one point, which is the slope of a tangent line!
Using the definition of a derivative is a pain in the ass. There is an alternative definition using the same slope formula for the slope at one specific point that you can use instead if you don't need the derivative function.
$$ \lim_{x \to a} \frac{f(x) - f(a)}{x - a} = f'(a) $$
This is much simpler to compute, however it only works for the one value $a$. Don't mix it up and think you can plug in any value once you simplify to get the slope at any point!
No worries! Calculating limits is hard, that's why there are rules to save yourself time when calculating derivatives. Hopefully you'll never have to use the definition of a derivative to find it.