It was one of hachigyaku (eight unpardonable crimes) in the ancient ritsuryo code (legal code of the Nara and Heian periods in Japan). It referred to crimes of descendants against their grandparent(s)/parent(s) other than akugyaku (homicide).
In the Middle Ages it meant a declaration of extinction of a family relationship by grandparent(s)/parent(s) on their descendants. It was a synonym with 義絶 (gizetsu or disownment). In and after the Edo period it was called kando (disowning).
From the early modern times to the present the kanji 不孝 was read as 'fuko' and meant immoral acts of descendants giving mental load to their grandparent(s)/parent(s).
Undutifulness to one's parents
Fukyo' in the ritsuyo code
It refers to illegal acts done by children (or grandchildren) to their parents (or grandparents) such as follows; filing a suit, cursing, abusing, becoming independent by removing names from the koseki (family register) or inheriting properties without permission, getting married during the time of mourning for parent(s) or grandparent(s) (for one year), indulging in entertainment such as music, taking off mofuku (the livery of grief), staying calm without feeling sad to hear the death of their parent(s) or grandparent(s) and having affairs with concubine of parent(s)' (grandparent(s)') by telling a lie that they were dead. Punishment for these behaviors was imprisonment, and especially filing a lawsuit against parent(s) (or grandparent(s)) meant death by hanging, which was one of death penalties (in Ritsuryo law), and was regarded as a serious crime that even a member of the Imperial Family or Kugyo (court nobles) could not obtain reduced sentences. As for Chinese Ritsuryo law, neglect of kuyo (a memorial service for the dead) was regarded as fukyo, but it was not introduced in Japanese Ritsuryo law.
"Fukyo" in the Middle Ages
In the Middle Ages, unlike Ritsuryo law and the modern law, it referred to the disownment of children (grandchildren) by their parent(s) (or grandparent(s)).
Although there were some differences between the Kugeho (court noble law) and the Bukeho (samurai law), it included delinquencies such as violation of law, neglect of filial duties or carelessness, disobedience (violation of orders and instructions), misconducts or hostile actions and so on, which were approved without any evidence if parent(s) (or grandparent(s)) had claimed. A child certified as "fukyo" was driven away from home, deprived of everything including the rights to inherit the family and properties, and so on for which he was eligible as a legitimate child, and the property already given to them was returned to their parents or grandparents (kuikaeshi).
義絶 (gizetsu or disownment) was almost the same except that parent(s) or grandparent(s) should disclose the fact inside and outside the family and make an epistle of disownment as a proof and that they were excluded from complicity in a crime even if their child (or a grandchild) committed a crime. However, in the period of the Northern and Southern Courts, it became necessary to make an evidential document in order to avoid complications after death, and the term fukyo has come to mean the same thing as gizetsu. Moreover, from the early Muromachi period the act of kando (disownment), which originally meant extinction of the relation between master and servant, came to be applied to a familial relation and have the same legal effect as fukyo/gizetsu, resulting in that the term fukyo was no longer used. Therefore, in and after the Edo period the term "kando" came to be used to mean the extinction of the relation between parents (grandparents) and children (grandchildren), while the term "gizetsu" came to be used to mean other general acts of canceling the kinship by relatives.