Ammonia (NH3) acts as a base in water due to its nitrogen atom having a lone electron pair, allowing it to accept protons according to Brønsted-Lowry theory. Water is amphoteric and can act as both an acid and a base, but in the reaction with ammonia, it donates a proton, making ammonia the base. The geometry of water, with its bent shape and electronegative oxygen, influences its ability to accept protons, while ammonia's single lone pair makes it more favorable for proton acceptance. The energy dynamics of bond formation and breaking also play a role, as the process of forming NH4+ from NH3 and H+ is energetically more favorable. Thus, ammonia's behavior as a base is a result of its molecular structure and the energetics involved in the reactions with water.