I think there are a few reasons the guitar has become such a popular instrument. Some of those reasons are pretty obvious, where other maybe not so much.
Portability: An acoustic guitar is very easy to lug around, and you can play it anywhere, such as the park or your backyard deck. Try that with a grand piano! Even an electric guitar with a small amp is relatively portable compared with many traditional instruments.
Volume: Managed sensibly, guitars really aren’t very loud compared to other instruments. You can play or practice in an apartment or bedroom without bothering anyone. This just isn’t possible with brass and woodwind instruments, or even other members of the string family such as the cello.
Accompaniment to vocals: Guitars work well for solo singer/songwriters. If you would like to sing and play at the same time you don’t have a lot of realistic options.
Versatility: The guitar stands out in just about every musical genre you can imagine, from rock to jazz to metal to country to classical to blues and probably to a few more I haven’t thought of.
Ability to play lead and rhythm roles: The guitar can be part of the rhythm section, or it can be the lead instrument. Most often it is both, even in the same song.
Accessibility: Historically, it’s been very easy for music stores – and event department stores – to stock and sell guitars. Compare the area you’d need to display ten guitars with the area you’d need to display ten pianos.
Easy to learn: Just about anyone can play guitar. You don’t need special lessons, though you can study extensively if you really want to. For some people, learning a few chords and playing songs they like is enough.
Pop culture: If Elvis had been a bassoonist would we be living in a different world today? Who knows, but the rise of rock music, starting back in the 1950s, certainly did a lot for the popularity of the guitar.