Cats are carnivores and are nocturnal in the wild.
Their ancestors hunted at night when prey was active, and this behavior was carried through into their genes.
That's why cats, even domestic ones, are often active in the early morning and late evening hours, and prefer to rest during the day.

Another reason why cats sleep during the day is to store energy for hunting.
Even though domestic cats do not need to hunt for food, their instincts still tell them to conserve energy for potential prey.
Sleeping during the day helps them prepare for the active period that comes at night.
Additionally, cats tend to have short and frequent periods of sleep. They may sleep for several hours at different times of the day, which allows them to remain alert and prepared for any danger.
This is because in the wild they need to be alert to avoid predators and other threats.
Another important factor is that cats love comfort and warmth. Sun rays and cozy places in the house create ideal conditions for daytime sleep.
Cats use this rest to warm up and relax, which contributes to their overall well-being.