How can someone invent a spell? Snape has invented Sectumsempra, we all know that. But what interests me is the act of making spell. If all spells are invented, what does it say about magic in HP-universe?
It's never really touched upon in the books. The only things we know is that the user must have a great understanding of magic to be able to concentrate on the desired magical outcome. Then they must provide the correct incantation. Etymology appears to be very important here (think back to Hermione and the Leviosa incident; highlighting that pronunciation was of utmost importance). As the spells in HP are latin-based, a knowledge of latin would be important.
The most logical conclusion is that JKR chose not to go into too much detail on how magic works. It would have opened up far too many questions (one could write a whole book on how magic works), and it could have detracted from the books.