A patient may be tempted to rub their eyes if their eyes are itching or if they wake up and they're crusted together or burning a bit, but I always encourage my patients to avoid rubbing their eyes when they can. It's simply bad for the cornea to rub your eyes.
You can induce corneal changes in shape that can be long lasting.
You can also make whatever symptoms you're experiencing worse by rubbing the eyes. So, if your eyes are itching because of an allergy, and you're rubbing them, you're actually releasing more of the cells that are causing the itching. You're not helping the problem at all, rather, you're actually making it worse.
When in doubt and when you feel like you want to rub your eyes, a cold compress is a way to go. It'll help constrict those vessels and limit the itching and discomfort without actually having to rub the eye.