The biliary system has two main functions. One is to produce and deliver a digestive juice, and the other is to provide a route through which certain kinds of things are eliminated from the body.
Bile is a lot like soap. Soap functions to help you lift oily stuff into water. Without soap, oil floats as droplets on top of water and the two do not mix. Soap is composed of molecules that have oil-like properties at one end and water-soluble properties at the other. In a mixture of water and oil, soap will form tiny bubbles with oil inside, and the droplets will freely mix into the water. This is called "emulsification". Bile does the same thing. Bile is a chemical mixture with molecules that have oil-compatible properties on one end and water-compatible properties on the other. Bile makes tiny soap bubbles with oily food on the inside and watery stuff all around. Bile emulsifies oily food into the otherwise watery juice flowing in the intestine.
The reason that it's important to emulsify the oily food droplets is that there are tremendously important nutrients and vitamins that are only available inside the oily stuff. If the oil floats as giant droplets through the intestine without mixing into the water, then all the digestive enzymes needed to break it down would not function correctly. The digestive enzymes that have to act on the oily food substances are floating in the watery juices. They can only act on the oil at the oil-water interface.
When chemistry depends on the conditions found at an interface such as the surface where water touches oil, we describe it as "surface area dependent". In this case, the job is to digest all the good stuff in the oil, so the best way to do this is to make the oil droplets tiny. That way there's plenty of surface on the droplets for the enzymes to do their digestion, and the droplets are processed very quickly.
Without bile, the oil droplets would be very large and the process of enzyme digestion would be incomplete by the time that the oil went all the way through the small intestine. Once oil gets to the colon, the window of opportunity is closed. The colon doesn't do a lot of nutrient absorption. Also, the rich nutrient supply of oil, if it gets to the colon, causes a bacterial bloom, and it draws water into the colon as well. The result is diarrhea. It's actually a very stinky kind of diarrhea that floats (like oil) and it's called "steatorrhea".
So that's the first main function of bile. It's a juice that assists with the digestion and absorption of fatty/oily nutrients that don't mix well with water. It works a lot like soap.
Another function of bile is to be a route of elimination.
Not everything in the body's tissues that needs to float out through the blood and then be filtered out of the system can exit in the urine. The urine is a great way to get rid of things that dissolve in water. However, some chemicals that tbe body needs to eliminate do not dissolve in water. These are often filtered out of the blood stream by the liver, and are either modified so that they DO dissolve in water (so that they can exit in the urine) or else they get put into the bile system and are excreted into the intestine where they flow out with the stools.
In particular, bile is rich in a chemical called "bilirubin" (notice the similar root words?). Bilirubin is a breakdown product that is made out of used-up hemoglobin. Hemoglobin is the oxygen carrying molecule in red blood cells that makes them red. Bilirubin is why bile is a dark green, or even brown/black color.
If something happens and the bile system gets blocked (there are a number of ways that this could happen), then the color of bile is absent from the poop. The normal brown color that we're all used to is replaced by having no color at all. The stools are actually silvery white, without bile.
In the mean time, all that stuff backs up in the blood stream, and people turn bananna yellow as they get sicker.
Many substances are eliminated in bile, but bilirubin is the most obvious one because of the striking color changes associated with blockage.
So that's the second function of bile. It's a route of elimination from the body, for things that don't dissolve well in the water and which are cleared by the liver.
I hope that answers your question. It was a good question.
I'm a surgeon.