Most people in the military who need a clearance only need a SECRET level clearance. It is good for 10 years. You have to fill out Form SF86. You can download it on .pdf. It will go back 10 years in your history. The amount and detail of information varies with the level of security clearance requested. It may include family information, past and current work history, drug use, locations where you have lived, schools, roommate names, financial history, travel history, groups or affiliations, and more.
Penalty for lying means you don't get the clearance, which will implicate in your military career. OPM (Office of Personnel Management) reviews and approves off on the clearance after the SF86 review. It may take anywhere from 6 months to a year. They have field agents that go out and talk to the people you listed on the form. You yourself may have an interview with an OPM officer. The worst thing you can do is lie. Not only will you not get the clearance in the beginning, but you can get your clearance revoked after the fact. My soldiers had a big concern about drug use. Kind of hard to do when you have periodic urinalysis conducted for drug use. I told them to tell the truth. However bad what you are trying to hide is, nothing pisses a OPM officer more than people who lie. In fact, they don't really care about drug use and other things, but they do care about liars. OPM had some really beautiful female officers in my days.