A musical idea is what inspires you to start writing music.
A musical idea is a short sound, about four seconds long, and sufficiently interesting to grab your attention and motivate you to write. Typical ideas include:
To generate a musical idea you doodle. Sing, whistle, hum, play about on a piano or guitar or computer or whatever, tap your fingers, read, or just sit and think. Many of us do this, find it immensely satisfying, and are constantly surprised when something turns up out of the blue. When nothing comes, no matter how hard you try, then choose anything, however trite or banal it sounds, you will undoubtedly be able to tweak it into something else later.
I have a folder on my computer labelled Riffs to store any and all ideas that look promising. It was huge. Eventually I learned to declutter and threw out everything that was less than one minute long and untouched for six months or more. It is disheartening to throw something away that sounded absolutely brilliant when you first wrote it but you have to be ruthless. Cheer yourself up afterwards by searching the internet for posts that begin: I have an idea for a song but ...
One tip is to think of a musical idea as an end not a beginning. Although the musical idea is what starts you off writing, it is not necessarily going to be the first sound in your opus. It might appear at the beginning, but, equally well, it might appear at the end, in the middle somewhere, or repeated at regular intervals throughout. Once you have an idea, then thinking of it as something to aim for might give you some useful pointers about how to get there, some of which in turn can be developed into new ideas in their own right.