It’s Rowling’s own birthday. But also, she wanted Harry’s birthday to be at the end of a month so the prophecy could say “born as the seventh month dies”. She wanted to have various events happen around Harry’s birthday which were easier to fit in if they happened during the summer holiday. Muggle holidays don’t start till mid July and the Hogwarts school year starts the day after the end of August, so 31st July was the only end-of-month which fitted the bill.