Was most of Egypt not a desert in the ancient times? Don’t lions live in grasslands?
The climate of Egypt in pharonic times (beginning around 3000 to 2500 BCE) was relatively similar to the climate of Egypt today. At that time, there actually weren't that many lions in Egypt.
But about 10,000 years ago, the Sahara was not a desert, but a lush grassland full of hunter-gatherer groups. As the region dried out people settled into the Nile Valley and became more organized out of necessity.
During this organizational period, there were still lions in Egypt. They were revered and there is some evidence that some were even tamed. It was during this period that beliefs around lions and their association with the king was formed. The belief endured even after the lion territory shrank deeper into Africa.