I think part of it is the ‘god of the gaps’ thing, to explain things in the natural world that people didn’t or still don’t know or understand.
The ability to perform miracles kinda goes hand in hand with immortality, since it goes against what we see in the natural world but wish could be different. Naturally people don’t want to suffer or die, so it’s nice to believe in an immortal god(s) who can defy the laws of nature and grant protections, miracles or answers to our prayers or wishes… especially for life everlasting and a reward for the ‘faithful’ in the hereafter. It also works nicely for earthly rulers who need soldiers who believe they will get their reward or pie-in-the-sky for being faithful and loyal even unto death on the battlefields to advance or expand their kingdoms or territories. Very convenient…

