Recursion is mainly used to save the lines of code (code re-usability).
For example, while writing a code for tree(data structures), it saves lump-some of lines of code.
It makes a code more modular & optimized.
Recursion should be used where memory (stack) is not a constraint because recursion gives a very hard time to our stack.
Though it is slower than loops, it has its own advantages too. Also debugging becomes difficult while using recursion.
Hope this helps!