Your cars engine bays cleanliness is something that is very crucial over the long run. It is constantly exposed to the outside elements from below the bay and gets riddled with dirt and grime from the engine itself, especially if the car previously had an oil leak. Eradicating the engine bay of dirt and grime, then, helps all the components function optimally. You can do it at home if you have access to a water hose and some cleaning products, at a car wash with a pressure washer, or you can have it professionally done if you don't want to do it yourself.
Before you get to it, though, remember to let your engine cool off for at least 30 minutes if it was just running as spraying cold water on hot metal and plastic parts can cause them to contract at a rapid rate and crack. Also remember to remove your negative battery cable to lessen the risk of damaging any electrical components. Then, cover the battery, alternator, and distributor with plastic bags so that they don't get wet, and then spray the engine bay with a degreaser. You can typically find a degreaser at your local auto parts store.
At the end of it, remember to dry the engine bay using microfibre towels, and then put all connections and wires back to their original state. This is all key to increasing the longevity of all the components within your engine bay, and reducing the chances of having failures while driving.