6 speed would be better than the 5. It'll be easier mount and the shifter assembly should fit if you get the proper generation. Otherwise you'd have to do some modifications to the tunnel.
There's the Legacy GT/STI 6 speed that is shifted with a rod. This trans was used in all STIs and JDM Legacy H6 cars. There's the newer generation 6 speed from gen 4 up that is cable shift which uses 2 levers to operate the gear changes and is smooth to operate. This one was put in the Legacy with H4 in the USDM market. Same 6 speed with different gear ratios was used in the Crosstrek, BRZ and WRX. All cable shift.
2017 was the last year Subaru put a manual in a Legacy and that was the 2.5 models.
Somewhere on here a member posted about putting the 6 speed from a Crosstrek in his manual Outback. I don't remember the year of the car, but believe it was a 3rd Gen. His car was already manual but he wanted the lower gear range.
The problems you will run into is the CAN system in the car. Things will need sorting.
Unless you find a JDM import with engine, trans and computer, you would need to do A LOT of electrical work. And as far as I know, the only JDM combo is the Legacy GT with the STI trans and that car was a 3.0 R series.
Here's another thing to consider. The CVT in your car has a manual mode and the paddle shift. It's super quick with gear changes. It'll hold whatever gear you have it set in until you shift up which is good for long curves, preparation for heavy cornering and speed out of a curve. (Think racing.) It will shift down by itself only when you stop, putting the gear in 1, otherwise it will not shift up or down until you command it. This is handy in multiple ways. You can start from a stop in 2nd to control torque to the wheels when on slick surfaces. No clutch slip from a stop. Takeoff on flat or inclined surfaces is easy. You can drive the car like a heavy sports car and go crazy with it, but I suggest you work on improving the suspension characteristics. Which is cheaper and easier than a manual swap.
You cannot damage the car with paddle shifting. For instance, the computer knows the rev limitations. It will hold a gear at redline rpm. It won't let you downshift if the engine is going to over rev with the lower gear you are trying to hit until the rpm drops in the gear the trans is in. It's not mimicking gear ratios. It's programmed with the various gear ratios. I think a 2018 is programmed with 8. You can shift the trans without lifting your foot. Hold the accelerator to the floor, the computer puts the engine at the peak power band and you shift up down as needed, or want.
This is a video about a WRX with a CVT. Same applies to the Outback; sorta. The Outback is a lot heavier.
I don't deter people from modifications. People thought I was crazy to supercharge an EZ30D. Now it's got a 6 speed and I'm working through electronic and computer control issues to get it to work like I prefer. My VDC is the first gen VDC and the ECM, TCM, ABS and VDC modules all work together to manage the car. No more TCM has created torque signal problems that affect the engine management. I am working it out as time permits.
https://www.subaruoutback.org/posts/6426369/