I noticed this about a week ago on my survival world that i have been playing on for over a month when i was building a monster farm and it didn't work. when i had built the monster farm i checked if there was any light in it and it was completely dark, i went AFK 30 blocks over it for about 20 minutes but when i checked the mob farm there was no monsters in it. I that i had designed it wrong and i went away over 500 blocks from it and built another one that was bigger, went AFK 30 blocks over it for several minecraft days but no monsters.
At this point i just decided to not build one and instead i did other things, i noticed that no mobs were spawning at night so i decided to not sleep and instead go out to try and find monsters, i went out several nights but i didn't even find ONE monster, i went down to some unlit caves but no monsters there either... at this point i started to try to find any way of solving my problem on the internet but nothing worked. After a while i also noticed that no passive mobs were spawning (sheep, pigs and those kinds of mobs) So i went to The End, set the difficulty from hard to peaceful and then to hard and enderman spawned, i then saw one guy on the internet who said that you should try to go VERY far from your location so i got a bunch of iron pickaxes and went to the nether and mined very far, placed a portal and jumped in. I got the advancement ''Subspace Bubble'' meaning that i had travaled over 7000 blocks. I started to walk around and noticed that passive animals were actually spawning! i don't think i have ever been so glad to see a chicken in minecraft. However when it became night i didn't see any monsters, i tried to sleep in a bed and after that i waited until it became night again but no monsters, next night there went the same. Not even a single mob.
I have tried to set difficulty to peaceful then to hard, /gamerule DoMobsSpawn true (even though it has always been on true), I have render distance on over 10 chunks, i have even tried to copy the world and play on the copy but still no monsters. if i make a new world monsters spawn. So basically one day i just closed minecraft and the next day i decided to play on it but no mobs spawned, i have not changed /gamerule and i don't know what has happened. Please help i have been playing on this world for over a month and never encountered this problem before.