With all the recent advances in understanding infinitesimals, we still don't fully understand why Leibniz's definition of $\frac{dy}{dx}$ as literally a ratio works the way it does and seems to explain numerous facts including chain rule.

To respond to the comments below, note that Robinson modified Leibniz's approach as follows. Suppose we have a function $y=f(x)$. Let $\Delta x$ be an infinitesimal hyperreal $x$-increment. Consider the corresponding $y$-increment $\Delta y=f(x+\Delta x)-f(x)$. The ratio of hyperreals $\frac{\Delta y}{\Delta x}$ is not quite the derivative. Rather, we must round off the ratio to the nearest real number (its *standard part*) and so we set $f'(x)=\text{st}\big(\frac{\Delta y}{\Delta x}\big)$. To be consistent with the traditional Leibnizian notation one then defines new variables $dx=\Delta x$ and $dy=f'(x)dx$ so as to get $f'(x)=\frac{dy}{dx}$ but of course here $dy$ is not the $y$-increment corresponding to the $x$-increment. Thus the Leibnizian notation is not made fully operational.

Leibniz himself handled the problem (of which he was certainly aware, contrary to Bishop Berkeley's allegations) by explaining that he was working with a more general relation of equality "up to" negligible terms, in a suitable sense to be determined. Thus if $y=x^2$ then the equality sign in $\frac{dy}{dx}=2x$ does not mean, to Leibniz, exactly what we think it means.

Another approach to $dy=f'(x)dx$ is smooth infinitesimal analysis where infinitesimals are nilsquare so you get equality on the nose though you can't form the ratio. On the other hand, Leibniz worked with arbitrary nonzero orders of infinitesimals $dx^n$ so this doesn't fully capture the Leibnizian framework either.

In an algebraic context one may be able to assign a precise sense to the Leibnizian generalized equality using global considerations, but I personally don't know how to do that precisely.