Rather is usually used in comparison statements.
I'd rather have a cat than a dog. I would rather go barefoot than wear shoes.
Prefer can be used in comparison statements (if you include the word "over" in the sentence), but usually just states a preference, with no comparison.
Using prefer in a comparison statement (with "over"): I prefer chicken over fish. I prefer sunshine over rain.
Also, prefer can be used in comparison statements if "as opposed to" is added in the sentence.
Using prefer in a sentence (with "as opposed to" added): I prefer sunshine as opposed to rain. (This usage is not common, but acceptable.)
*In the US spoken English, "rather" statements are used more commonly for comparisons.
Common usage of prefer(no comparisons): I prefer chocolate ice cream. I prefer low impact exercises.
I hope this was helpful. :)