The Short Answer
A Layer 3 switch routes IP in its switching hardware, so it moves traffic between VLANs and subnets at close to wire speed, with high port density, inside a site or platform. A router routes in software at lower throughput but connects networks to the outside world, with WAN interfaces, NAT, VPNs and a wider protocol set, and far fewer ports.
Which to Use
Use a Layer 3 switch for fast routing between segments on site; use a router at the boundary to everything beyond it. Many networks use both: the switch handles local inter-VLAN routing, the router handles the uplink.
For more, see our guide to Layer 2 vs Layer 3 switches, or browse our industrial Ethernet switches.