Kegarë is a central concept in Shinto, and is normally translated as “impurity”. This is not a bad translation, but it is also not quite right. Sometimes, kegarë is referred to as “tsumikegarë”, which is translated as “sin and impurity”. This is also not quite right.
The first point to make is that “impurity” is a better translation than “sin”. Traditionally, for example, childbirth attached a great deal of kegarë to the mother, but childbirth was certainly not regarded as a sin; indeed, it was the primary function of a woman in society. (Like all religions with a history, Shinto has a history of sexism.) What’s more, physical dirt is a form of kegarë, and physically washing it off is an important part of purification. Even more striking is the fact that being a victim of a disaster or a crime causes kegarë. Sometimes, kegarë is something that happens to you. It isn’t your fault in any way, but you are still impure.
On the other hand, sometimes kegarë does arise from your actions. Wrong actions, like moving boundary markers in fields (this is one of the things listed in the nearest equivalent Shinto has to the Ten Commandments — it’s not a very close equivalent), cause kegarë for the person who does them. People are, in some sense, damaged when they do something that is wrong. Wrong actions can also, of course, cause kegarë for the victims of the action, as noted above.
The precise nature of kegarë is unclear, largely because, as I have mentioned before, Shinto does not have a tradition of analytical theology. It is generally believed that having a lot of kegarë is bad for you, in the same way as being ill is bad for you. Indeed, being ill might be a result of having a lot of kegarë, as might any other form of bad luck. One popular etymology for “kegarë” is that it comes from the words for “spirit” and “wither”, so that kegarë represents a lessening of your energy. This means that you are less capable, less creative, and more prone to mistakes. It is also connected to damaged relationships with other people, and an inability to take stock of and address your own problems.
Kami are said to really hate kegarë. This is why you are supposed to rinse your hands and mouth before approaching a jinja, to make sure that you are not carrying kegarë into the sacred area. Performing a matsuri while carrying kegarë is a major taboo. The matsuri in which a newborn baby is presented to the kami is a good example of this. This matsuri was traditionally performed when the father and the child had been purified of the kegarë caused by childbirth. However, at this point the mother was still considered to be suffering kegarë, so she could not enter the jinja. Instead, the baby was carried by its paternal grandmother. This last custom is maintained today, although most shrines do let the mother attend as well. More generally, priests are required to undergo purification before officiating at matsuri, to remove any kegarë they have picked up in their daily lives, and anyone attending a matsuri is purified before it starts.
Kegarë, then, is something that you get by doing the wrong thing, or because something bad happens to you. If you have kegarë, things are more likely to go wrong, and you cannot approach the kami. The ceremonies of haraë, which remove kegarë, are thus a very important part of Shinto.
How might one go about getting rid of kegare? I know that you mentioned ritual cleansing of physical dirt and other removable impurities that might find themselves on an indivdiual, but how would someone go about cleansing themself of the metaphorical kegare? Is the mother ever pure again after giving birth to her child? Is the victim of a crime ever able to escape the impurity left from the event?
Kegarë can be removed through oharai, or haraë. I wrote an essay about that for my Patreon, and there are shorter articles about it on this site, which I suspect you have found by now. The removal of kegarë is a central part of Shinto belief and practice, and there is no such thing as permanent kegarë, at least not these days.