Dish detergents are surfactants, which basically allow grease and oil to mix with water by lowering its surface tension. Although water alone can't remove grease, lowering the surface tension makes it possible to rinse away grease and oil.
Dish detergents were developed following a shortage of vegetable and animal fats, which were used to make soap during WWI and WWII. Surfactants are made using petrochemicals. The goal of all surfactants is to lower surface tension, which makes water less likely to stick to itself and more likely to interact with grease and oil.
Modern dish detergents differ from early detergents in that they contain more than just surfactants. Companies often add other materials to give their products more cleaning power. This includes bleach to remove color stains and enzymes to break down protein-based stains. Many detergents also include blue dye to prevent yellowing.
Just like soap, detergents have hydrophobic and hydrophilic molecular chains. On one end of the chain is the hydrophobic component that repels water but is attracted to grease and oil. On the other end is the hydrophilic component that is attracted to water. This makes it possible for the molecular chain to attract both water and grease.