E‑signature legal validity explained

How does e-signature work?