As i understand it, invalid indicates that there’s a defect so severe that the sacrament is rendered null. For example, the celebrant is actually a layman, or rice cakes and soda pop is used, or one is baptized in the name of the Creator, the Redeemer and the Sanctifier. In such cases there is no sacrament at all.
Illicit indicates that there’s some lack of conformity with Church law, which doesn’t necessarily render the sacrament invalid. For example, a schismatic Bishop ordains a man without the permission of the Holy See: the ordained man is really ordained, it’s a valid ordination, but it’s illicit because it was done in violation of the law. Similarly, masses celebrated by the illicitly ordained priest are valid (assuming that they are otherwise celebrated correctly), because he really is a priest, but are illicit because he has no faculties from any legitimate authority. This is a very serious matter, and I can think of very few circumstances in which I’d knowingly attend such a mass… In fact, I can’t think of any at all.
If I were in imminent danger of death I’d approach such a priest for confession and last rites, if there was no other option. Church law does allow for that.