Why is data fragmentation not possible on main memory (RAM)?
According to https://lwn.net/Articles/211505/, what you imagine should be done by the OS, is already done:


  Since Linux is a virtual memory system, fragmentation normally is not a problem; physically scattered memory can be made virtually contiguous by way of the page tables. 


There are limits to this, as hardware devices may request contiguous hardware memory, and this creates memory holes (at least for hardware devices).

Another limitation is that doing all memory allocations and deallocations through page tables is inefficient. Setting up new page table entries takes longer than managing allocations through software and, if the page size is 4K, only works for allocations that are a multiple of 4K. Therefore the malloc and free glibc calls first allocate 4K blocks through mmap (using page tables) and manage this memory. They divide it into smaller contiguous memory areas and return them when a malloc call requests a small chunk of memory. Algorithms to reduce memory fragmentation of software-managed memory are for example the Buddy memory allocator.