To rub is to push firmly and repeatedly, like when you rub your sore foot. When Hamlet says, "aye, there's the rub," he's not talking about getting a massage. Rub, as a noun, is an obstacle or something in your way.
You can rub someone's aching back or rub sunblock on your arms and legs. You can also watch chunks of melting ice on a lake's surface rub against each other or complain that your new shoes rub your heels and give you blisters. Colloquially, you might rub off on your friends, or begin to influence them by your mere presence. If, however, you rub them the wrong way, you irritate or annoy them. The noun rub is not used nearly as often as the verb, but people do love to allude to Hamlet's "aye, there's the rub" line in the "to be or not to be" soliloquy, referring to the unforeseen dreams of death that haunt mankind.