A programmable logic controller (PLC) continuously monitors inputs from sensors and uses a custom program to control outputs to devices. PLCs were created to eliminate the inflexibility and high costs of relay-based control systems. Prior to PLCs, control systems used electromechanical components like relays which required extensive rewiring for changes and were prone to failures. PLCs are easier to reprogram, more reliable, and provide integrated diagnostics compared to hard-wired relay systems.