What happens when all 21 million bitcoins are mined? How will transactions be archived if no one is putting in the effort to mine bitcoins?
Bitcoin transactions can optionally provide transaction fees which are paid to the first miner to include their transaction. Blocks have a limited size in order to prevent the biggest nodes from centralizing the system by producing more load than smaller ones can handle, so there will be competition for access to that limited space. Miners can then be funded collecting these fees.