A fastener is a device that joins two or more objects together. In general, fasteners are used to create non-permanent joints; that is, joints that can be removed or dismantled without damaging the joining components. (As opposed to say welding).

A resin is an adhesive. A solvent is a dissolving agent.

Glue in a tube does not try up because glue must be exposed to air to harden.

The reason for the different styles is cost and torque. The slotted head screws are cheap and easy to make. But they're completely useless for powered screwdrivers and you can't put much torque on the screw without it either slipping out or stripping the head (and maring the surface of whatever you're screwing). Phillips screws are self-centering, making powered screwdrivers possible. They're somewhat more expensive to produce than slotted-head. They tend to 'cam-out' easily under torque, making it hard to apply much torque. I've heard they were designed that way to prevent overtightning. However, it's not good for exposed fasteners to look stripped. Robertson-head and allen-head fasteners can handle more torque than phillips-head fasteners, but are more expensive. Because the bottom of the hole is flat (unlike the pointed end of the phillips), there's more contact area and so it's less likely to cam-out. The robertson-head is cheaper than the allen-head, but the allen-head has six points of contact rather than 4, making it less prone to rounding out the hole. The Torx-head fasteners solve the problem of rounding/stripping by having the flat bottom of the robertson/allen that reduces cam-out, but it has much better contact with the driving bit to prevent stripping the head. The points of the 'star' on the driving bit engage the recesses on the screw at nearly right angles, so it has a very positive contact. Torx is becoming more and more popular because of that, particularly in assembly-line work. Because they're less likely than a phillips to be damaged when tightening, the allen (internal hex) heads are often used for exposed ('decorative') fasteners on 'some assembly required' furniture. It's also very cheap to make the allen keys, so they usually include one with the fasteners.

One thing not mentioned is that some screws (e.g. Robertson) are better for automatic machine use than others.

For machines, it's best if you can load the screw onto the driver, then move the driver into position. But you need a screw that will hold onto the bit well enough to not fall off.

You've got some good answers here already, but they're all leaving out an important aspect, which is how the screw and screwdriver deal with fouling. Dirt, oil, weld slag, multiple layers of paint, whatever. If you're in an environment where you don't have to worry about that, a complex geometry is fine. But on a factory floor, Phillips or torx can get irreversibly fouled. Allen head screws can be relatively easily cleaned, but the master of this is the shittiest of all screw heads, the flat head. The only tool you need to clear the slot of a flat head screw is the screwdriver you're going to use to unscrew it. No other screw type has that ability.

This is why you see flathead on a lot of military firearms. You can take it apart & put it together with anything that will fit and be strong enough to not bend or break. (Such as a knife, coin, or metal button.)