Dental Enamel is the outer part of a tooth; the part you see. It coveres the tooth like a thick eggshell. In baby teeth, it is quite thin. In permanent teeth, it is thicker, roughly 1-2mm. It is very hard. Under a microscope the enamel "rods" are arranged kind of like a stack of lumber with the surface being the ends of the stack. These rods have sort of a keyhole shape in crossection.
In order for a composite filling, sealant or other bonded material to adhere to the enamel, the surface is "etched". This is usually done by applying 37% phosphoric acid solution for about 15-20 seconds and then rinsed off. (No the acid does not hurt. In fact, you can touch it for a good while and nothing will happen. It's acid, but not that strong). The etchant removes inorganic material and parts of the enamel rods whose ends are exposed by demineralization. Yes, if you put an egg into vinegar it will eventually demineralize the eggshell. Same thing here, but a much shorter time, stronger acid and it's only the microscopic surface that is demineralized. This etching produces multiple areas for bonding material to mechanically adhere to the enamel surface. Visually the tooth has a frosted appearance. It's sort of like sandblasting or priming the surface. Bonding agent is then applied, flowing down into this rougher surface. Once curing occurs, this locks into the undercuts, and bonds the material to the tooth.
Dentin can also be etched, but the bond strength is less than with the enamel. It is much more organic with dental tubules evident on microscopic view. Newer bonding agents bond to enamel and dentin. You can see from these photos how the surface is primed for bonding.