β-galactosidase is the commercially made version of lactase, the enzyme necessary to break down lactose, or milk sugar. While β-galactosidase is not difficult to manufacture (it is harvested from fungi in the genus Aspergillus), it is hard to deliver it intact to the small intestine at the right time and in a functional condition. The enzyme must arrive in the intestines at the same time as the lactose containing food does, or it will not do any good. Additionally, this enzyme, like many proteins, can become denatured under extreme pH conditions, including those found in the human stomach. When a protein is denatured its tertiary and secondary folding structure is altered permanently. In the case of a protein serving as an enzyme, denaturation usually renders the enzyme nonfunctional.
As you have pointed out, drinking lactase, particularly on an empty stomach, may not be effective. This is true because the enzyme is denatured by stomach acid, and is thus nonfunctional when it reaches the small intestine.
People who are lactose intolerant are unable to digest lactose, a sugar found in dairy products. They have a deficiency of the enzyme lactase. When lactose is hydrolyzed or digested, it becomes glucose and galactose. People with this enzyme deficiency are unable to digest milk sugar causing symptoms like diarrhea and cramps. In the course of a mammal's life cycle, the ability to digest milk usually decreases after they have become weaned off of breast milk. However, human mammals continue to drink milk and consume milk products during their lives. Although many humans continue to produce lactase as adults, the levels usually decrease somewhat.