Quality is in the eyes of the beholder...
The main things you have control of:
codec - you seem to want HEVC, which is fine. It is typically produces files that are smaller than the more traditional H264 codec, for comparable quality
frame size - 1080p, 720p... depending on the content, this may be an easy way to get a smaller file; then it will depend on the particular content and viewing device; in some cases, reducing from 4K to 1080p or from 1080 to 720p may not be very noticeable for the viewer - for example if watching on a phone screen, you are not going to get any benefit from a 4K video, and might as well serve a smaller version
bit rate - here you have a lot of latitude. Experiment! Note that how low you can go without perceived loss of quality will depend a lot on the content that you are compressing.