Firstly, "I'd rather you stayed here" actually means "I'd prefer you stayed here instead of going somewhere else". "Rather" has a sense of comparison. Would you rather tea or coffee - would you prefer tea or coffee. So you would only use "I'd rather you stayed" if the person in question had indicated an intention to leave. If they had not shown an intention to leave, but you still wanted to let them know that you liked them being there and didn't want them to leave, you would say "I'd like you to stay".
If you were telling someone that you preferred to stay somewhere, instead of leaving, you could say "I'd prefer to stay here", or, "I'd rather stay here". Both of these have that sense of comparison - you are indicating a preference for staying there over an (unstated, but presumably understood) alternative - such as leaving, or staying somewhere else. If you say "I would like to stay here", then you are simply stating a fact, rather than a preference over an alternative.
It is like the difference in Japanese between 何のほうがいいです and 何がすきで。