The primary function of an oil seal is to create a barrier between the rotating or moving parts of a machine and prevent oil or other fluids from leaking out. This helps to ensure that the machinery operates smoothly and efficiently without any loss of lubrication or contamination of the surrounding environment. In addition to preventing leakage, oil seals also help to retain lubricant within the system, extending the life of the equipment.