Your arr variable is global, meaning that if I were to call your function twice in succession the data would be written in the same “place”.
Or in other word:
rangeOfNumbers(1, 5) // [1,2,3,4,5] OK
rangeOfNumbers(6, 9) // [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] NOT OK
As a rule of thumb you want to avoid global variables as much as you possibly can.
Now, if you move your global variable inside the function body it will solve the overwriting error. However you will still need to change slightly how you return and push into that array when using the recursion.
the easiest one to conceptualize and do would be to have an answer array, then another function within your rangeOfNumbers function exclusively to deal with recursively pushing elements into the answer array.
A little bit harder is to use rangeOfNumbers itself, by returning partial arrays that gets concatenated to each other as you go through the steps of recursion.