It looks like a relatively simple problem, but I found some difficulties finding a way to express the difference between two numbers as a number in between $0$ and $1$ (you can say as a percentage).
Rules are simple: both numbers are always positive, and regardless of how big each of two numbers is, the difference between them must be expressed as any number between $0$ and $1$.
A usual
$\frac{x-y}{y}=$ difference
Doesn't work here, since if $X$ is much better than $Y$, their difference will be expressed as a number larger than $1$. Any simple variation of this formula gives the same results.
How would you make sure that difference can be expressed within boundaries of $0$ and $1$, regardless of how big or small either $X$ or $Y$ is?
Let the two numbers be $a$ and $b$ which are positive integers and let $x=a-b$. You could use the sigmoid function or any variant of it as it is used in neural networks in computer science, only retuning a number of 0 to 1. The function is:
$$f(x)=\frac{e^x}{e^x+1}$$
If you feel this goes from 0 to 1 too quickly and only expresses the difference between two small numbers accurately, you could change the value of $c,n\in\mathbb{R}^+$ in:
$$f(x)=\frac{e^{\frac{1}{n}(x-c)}}{e^{\frac{1}{n}(x-c)}+1}$$
You can use this https://www.desmos.com/calculator/x0budxt4uq as a visualisation, though really large differences (which is denoted by d in the desmos graph), eventually leads to the function equalling $1$ (or so close the computer can't calculate the decimal points). You can also use any of the functions on https://en.wikipedia.org/wiki/Sigmoid_function under the examples section, which also all give out a number from $0$ to $1$ no matter the input. To summarise, it is probably impossible to find a function which expresses the difference between two numbers linearly, as I am pretty certain it has to exceed one at one point. You will probably have to use functions which asymptote at $0$ and $1$ such as the sigmoid function of functions alike. I hope this helps!