Layers are born/designed due to the requirement for scalability and improving security.
Layer 1 is a blockchain while layer 2 is a third party integration on the blockchain. Eg of layer 1 blockchains include: bitcoin, ethereum 1.0, litecoin, solana, BSC and others.
The blockchain overtime has shown strength, immutability, transparency but inconsistencies when it comes to scalability.
Due to the steady increasing amount of nodes on the blockchain, layer 1 seams to be falling short. Blockchains like bitcoin processes over 5TPS and ethereum, 15TPS (transactions per second) amongst many others. Therefore this makes them not scalable enough to accommodate the steady growing amount of nodes on the blockchain.
This is a secondary framework or third party integration connected/built on top of layer 1 to be able to accommodate an increase in the number of nodes, processing times i.e. the time it takes to verify transactions and throughput by sharding.
Sharding is a way of spreading out the nodes into smaller groups/partitions instead of piling up on a single chain i.e. the main chain which in turn can cause delay and lead to branching. This groups are know as shards.
These shards are independent nodes which achieve consensus together to verify and carry out transactions after which they send it to the main chain i.e. the beacon chain to be recorded on the blockchain. This technique is said to be applied in layer 2 blockchains like ethereum 2.0. It is structured to increase processing times, throughput and in turn make decentralized networks scale.