To get into the Ravenclaw dormitory, they need to answer a riddle. What if they don’t know the answer? How will they get in?
You wait for somebody else to show up.
When Harry first encounters the eagle, Luna explains what happens if you get the question wrong. If you don’t know the answer, you wait for somebody else who does. Same as all the other dormitories, except (this being Ravenclaw) there’s a vague hope that you’ll learn something by doing so:
“What? Isn’t there just a password?”
“Oh no, you’ve got to answer a question,” said Luna.
“What if you get it wrong?”
“Well, you have to wait for somebody who gets it right,” said Luna. “That way you learn, you see?”
— Deathly Hallows, chapter 29 (The Lost Diadem)
According to the Pottermore welcome letter for Ravenclaw, it’s not unusual to find people stumped by the riddle, waiting for somebody to come along and help them out:
It’s not unusual to find twenty people standing outside the common room door, all trying to work out the answer to the day’s question together. This is a great way to meet fellow Ravenclaws from other years, and to learn from them – although it is a bit annoying if you’ve forgotten your Quidditch robes and need to get in and out in a hurry. In fact, I’d advise you to triple-check your bag for everything you need before leaving Ravenclaw Tower.
Note the phrase “the day’s question”. It sounds as if the raven changes the riddle once a day, which sounds about right. Most people will leave Ravenclaw Tower at least once a day, and so get the benefit of the day’s riddle, it won’t stagnate because everybody already knows it, and it’s not changing enough to be too annoying.
(And having said that, @chirlu points out in a comment that this is directly contradicted by the encounter in Deathly Hallows.)
If a Ravenclaw or non-Ravenclaw cannot answer the riddle you must wait until one answers the riddle correctly. Most 1st years of Ravenclaw wait for hours outside Ravenclaw Tower because they cannot answer the question, However, they watch and learn. Eventually, it becomes a challenge to see who will answer it correctly first, which means after your 1st year you will know how it works and look forward to every challenge. It does get quite annoying though if your in a hurry to get your Quidditch materials which you left inside the Tower.